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

Setting jcr:Property of type Date with value dynamically

sagarv13144480
Level 3
Level 3

I understood on how set jcr:property of type date by doing this

Calendar cal = Calendar.getInstance();

node.setProperty("publishDate",cal);

How to add a property of type Date using Java?

What it does is it sets property with Name and type date but value it takes as the current Local time.

I want to update value.

Can anyone help.

1 Accepted Solution
Arun_Patidar
Correct answer by
Community Advisor
Community Advisor

Hi,

You don't need to do anything

Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));

child.setProperty(cpropertyName,calendar);

View solution in original post

4 Replies
Arun_Patidar
Community Advisor
Community Advisor

Hi,

did you try different methods or other ways to setup time.

e.g.

Calendar.getInstance(TimeZone.getTimeZone("GMT"));

sagarv13144480
Level 3
Level 3

Hi Arun,

I did actually

but while setting property it is prompting me to Cast argument to (Value).

DateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'+00:00'");

        

            java.util.Date date = inputFormat.parse(inputDate);

      

        Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));

        calendar.setTime(date);

child.setProperty(cpropertyName,(Value) calendar.getTime() );

When i do cast, it is giving error while setting metadata

"javax.jcr.Date cannot be casted to javax.jcr.Value"

Arun_Patidar
Correct answer by
Community Advisor
Community Advisor

Hi,

You don't need to do anything

Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));

child.setProperty(cpropertyName,calendar);

View solution in original post