Setting jcr:Property of type Date with value dynamically | Community
Skip to main content
Level 2
May 20, 2019 9:43 AM UTC
Solved

Setting jcr:Property of type Date with value dynamically

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
arunpatidar
arunpatidarAccepted solution
New Participant
May 22, 2019 10:08 AM UTC

Hi,

You don't need to do anything

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

child.setProperty(cpropertyName,calendar);

Arun Patidar

4 replies

Level 2
May 23, 2019 4:58 AM UTC

Thanks Arun!

Translate
arunpatidar
arunpatidarAccepted solution
New Participant
May 22, 2019 10:08 AM UTC

Hi,

You don't need to do anything

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

child.setProperty(cpropertyName,calendar);

Translate
Arun Patidar
Level 2
May 22, 2019 6:07 AM UTC

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"

Translate
arunpatidar
New Participant
May 20, 2019 11:09 PM UTC

Hi,

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

e.g.

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

Translate
Arun Patidar