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
BedrockMission!

Learn More

View all

Sign in to view all badges

Customizing the date

Avatar

Avatar
Validate 25
Level 3
Jai1122
Level 3

Likes

21 likes

Total Posts

127 posts

Correct Reply

2 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 5
Boost 3
View profile

Avatar
Validate 25
Level 3
Jai1122
Level 3

Likes

21 likes

Total Posts

127 posts

Correct Reply

2 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 5
Boost 3
View profile
Jai1122
Level 3

15-10-2015

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!!

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 25
MVP
bsloki
MVP

Likes

182 likes

Total Posts

1,859 posts

Correct Reply

545 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile

Avatar
Validate 25
MVP
bsloki
MVP

Likes

182 likes

Total Posts

1,859 posts

Correct Reply

545 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile
bsloki
MVP

15-10-2015

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...

Answers (0)