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 save only time into JCR:Cotent and display it when open edit form?

bhoang
Level 4
Level 4

Hi all,

I was create a field for the user select time only. I set for the field as below:

displayedFormat: HH:mm

storedValue: HH:mm

type: time

valueFormat: HH:mm

However, it save to the JCR:Content as : 2018-08-10T11:16:00.000+07:00

And it can't display when I go to view properties page to edit.

How to save the time as HH:mm example: 11:16 ?

How to display it in the edit form after save it?

Thank you so much,

BienHV

1 Accepted Solution
Jörg_Hoh
Correct answer by
Employee
Employee

When you speak of "form", I assume that you are talking about page properties or component properties, is that correct?

In this case, the Sling Post Servlet handles the conversion of the date into a property with the JCR type "date". And the way, which CRXDE Lite is displaying it (I assume that you took the formatting from there) is one way to display it. That means, your simplified approach to store "time" is handled by the system in a way to store it as full "date object" including minutes, seconds, timezone etc.

Tat way you should also treat the object as full "date object" and format it according to your needs on the client side.

Jörg

View solution in original post

5 Replies
Jörg_Hoh
Correct answer by
Employee
Employee

When you speak of "form", I assume that you are talking about page properties or component properties, is that correct?

In this case, the Sling Post Servlet handles the conversion of the date into a property with the JCR type "date". And the way, which CRXDE Lite is displaying it (I assume that you took the formatting from there) is one way to display it. That means, your simplified approach to store "time" is handled by the system in a way to store it as full "date object" including minutes, seconds, timezone etc.

Tat way you should also treat the object as full "date object" and format it according to your needs on the client side.

Jörg

Arun_Patidar
Community Advisor
Community Advisor

Hi,

As Jorg suggested you cans ave date as it is but manipulate during display.

Or you can you below document to set date formats while saving and displaying? Please check if it helps.

DatePicker — Granite UI 1.0 documentation 

smacdonald2008
Level 10
Level 10

Are you working with the coral 3 date picker object?

datepick.png

bhoang
Level 4
Level 4

Thanks for your helps.

I do it in the coral UI. I can choose only time in the form. But it save date and time. And when I choose View properties of page to edit. It can't display the time I selected before. The requirement are select and save only time. I don't want to save date.

Please suggest me the solutions.

Thank you so much.

BienHV

Arun_Patidar
Community Advisor
Community Advisor

Hi,

You can save both date and time but when you use on page, you can only get time in HTL like below example to get last replication date

<p>Time - ${'HH:mm' @ format=pageProperties.cq:lastReplicated }</p>

Similar you you can do

${'HH:mm' @ format=properties.propName}

${'HH:mma' @ format=properties.propName}