Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

How to programmatically add Date object to crx repo

Avatar

Level 1

HI ,

 

I need to set date type programmatically  in crx repo so that it should work with both classic and touch UI datepicker.

Currently I am setting up as a string "Fri Dec 04 2020 13:08:08 GMT-0700" which is working for classic but not for Touch UI.

I have tried with using SimpleDateFormat (below format) to format string (eg) "2020-12-23T03:15:00.000+05:30"  it as date object but getting as null in crx.

yyyy-MM-dd'T'HH:mm:ss.SSSXXX

 Please let me know how to proceed here.

THanks

1 Accepted Solution

Avatar

Correct answer by
Level 5

Hi @Harsh161987 ,

 

please use below code to set date property to node.

String dateString = "your_date"
Calendar cal = new GregorianCalendar();
cal.setTimeZone(TimeZone.getDefault());
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
cal.setTime(formatter.parse(dateString))
node.setProperty("date", cal );

 

Thanks,

Sandeep.

View solution in original post

0 Replies

Avatar

Community Advisor

Hi @Harsh161987 ,

Can you please share code snippet the way you are setting this date property value.

 

Avatar

Correct answer by
Level 5

Hi @Harsh161987 ,

 

please use below code to set date property to node.

String dateString = "your_date"
Calendar cal = new GregorianCalendar();
cal.setTimeZone(TimeZone.getDefault());
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
cal.setTime(formatter.parse(dateString))
node.setProperty("date", cal );

 

Thanks,

Sandeep.