Trouble getting date diff

I’m having trouble working with dates. Here’s what is asked of me to do:
A content type has a Reviewed Date field. On index page, items reviewed in the last X days have to be marked (“New!”).

This is how I approached it:
Created two bindings on the snippet template. One reads current date ($, the other reads Reviewed date from item ($sys.item.getProperty(“rx:date_reviewed”)). The former returns, the latter is jcr property. If I do $sys.item.getProperty(“rx:date_last_reviewed”).getDate() I get gregorian calendar type. My idea is to get “time” property for both (number of seconds from set date) so I can compare/subtract the two. I can get that from the current system date ($ but got nowhere with the calendar.

I am not a java expert and was wondering if someone can help me, or suggest different approach.


The latest Velocity Tools has a “Comparison Date Tool” which will do what you want.

You will, however, have to “upgrade” your Velocity tools installation as described in this thread



We are still on version 6.0
Does it matter?

I have not tested it, but I don’t see why it won’t work.


Works like a charm. And yes, velocity-tools-view is good to go as well. Many thanks.

Giving back:

Actually, should I put this set of tools under “date” key in that xml config file?