How to programmatically add Date object to crx repo

Avatar

Avatar

Harsh161987

Avatar

Harsh161987

Harsh161987

02-12-2020

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

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Sandeep6

Avatar

Sandeep6

Sandeep6

02-12-2020

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.

Answers (1)

Answers (1)

Avatar

Avatar

Manjunath_K

MVP

Avatar

Manjunath_K

MVP

Manjunath_K
MVP

02-12-2020

Hi @Harsh161987 ,

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