Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Customizing the date

Avatar

Level 5

Hi,

   I am trying to display the date on which a particular item is created.

The issue is with formatting.

For instance,

    - If the item is created a day ago then i need to display 1 day ago.

    - If the item is created a on the same day then display number of hours like 3 hours ago.

    - If the item is created over a week ago then display complete date time like October 24, 2014 at 08:54 PM

com.day.cq.commons.date.RelativeTimeFormat

It displays something like Jun 3(1 day ago), for first case and 02:45 PM(3 hours ago) in second case. 

Can someone suggest any ideas to overcome this?

Thanks!!

1 Accepted Solution

Avatar

Correct answer by
Level 10

Refer [1] for the different letters you can use to get the respective format. I think you are using 'Y' now and hence your output is in the respective format.

ex: you should use 'ago' as the keyword for 1 day ago 

[1] http://wem.help.adobe.com/enterprise/en_US/10-0/wem/javadoc/index.html?com/day/cq/commons/date/Relat...

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

Refer [1] for the different letters you can use to get the respective format. I think you are using 'Y' now and hence your output is in the respective format.

ex: you should use 'ago' as the keyword for 1 day ago 

[1] http://wem.help.adobe.com/enterprise/en_US/10-0/wem/javadoc/index.html?com/day/cq/commons/date/Relat...