Skip to main content
bhoang
Level 4
August 10, 2018
Solved

How to save only time into JCR:Cotent and display it when open edit form?

  • August 10, 2018
  • 5 replies
  • 1832 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by joerghoh

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

5 replies

joerghoh
Adobe Employee
joerghohAdobe EmployeeAccepted solution
Adobe Employee
August 10, 2018

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

arunpatidar
Community Advisor
Community Advisor
August 10, 2018

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 

Arun Patidar
smacdonald2008
Level 10
August 10, 2018

Are you working with the coral 3 date picker object?

bhoang
bhoangAuthor
Level 4
August 23, 2018

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

arunpatidar
Community Advisor
Community Advisor
August 23, 2018

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}

Arun Patidar