How to programmatically add Date object to crx repo | Community
Skip to main content
New Participant
Dec 3, 2020 6:45 AM UTC
Solved

How to programmatically add Date object to crx repo

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Sandeep6Accepted solution
Level 4
Dec 3, 2020 7:30 AM UTC

Hi @hagupta ,

 

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.

2 replies

Sandeep6Accepted solution
Level 4
Dec 3, 2020 7:30 AM UTC

Hi @hagupta ,

 

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.

Translate
Manjunath_K
Level 7
Dec 3, 2020 7:29 AM UTC

Hi @hagupta ,

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

 

Translate