1

I have this SPEL expression in Hybris:

attribute->baseProduct.onlineDate that returns a java.util.Date;

However , when I try to get the Time in long :

attribute->baseProduct.onlineDate.getTime()

It throws an exception:

Attempted to call method getTime() on null context object

I don't understand why is this happening ,since getTime is a public method of java.util.Date. Any hint?

Nexussim Lements
  • 535
  • 1
  • 15
  • 47

1 Answers1

2

Can you please try attribute->baseProduct.onlineDate.time?

The other option is to do as follows:

Calendar cal = Calendar.getInstance();
cal.setTime(date);//where date is the value you are getting from attribute->baseProduct.onlineDate

After this, you can retrieve any part of the date and time from the cal object.

Note: with any of the options, please make sure that attribute->baseProduct.onlineDate returns a non-null value.

Arvind Kumar Avinash
  • 71,965
  • 6
  • 74
  • 110