user3518223
user3518223

Reputation: 205

How to get days difference between two dates in velocity templates?

I want to get days difference between today's date and a payment due date (next date greater than todays date) using velocity template. If my today date is 12/10/2016(MM/dd/yyy) and payment date is 22/10/2016(MM/dd/yyy),the date difference should be 10. I tried in difference ways, couldn not find the exact solution. Can anybody help me on this?

Upvotes: 2

Views: 5055

Answers (2)

Bogdan M
Bogdan M

Reputation: 121

$dateTool.getDate() is todays date.

Final statement is like so:

$date.difference($payDate, $dateTool.getDate()).days==10

Make sure you have ComparisonDateTool in tools.xml.

class="org.apache.velocity.tools.generic.ComparisonDateTool"
              format="MM/dd/yyyy H:m:s" depth="1" skip="month,week"
              bundle="org.apache.velocity.tools.generic.times" timezone="EST"/>

Upvotes: 1

Claude Brisson
Claude Brisson

Reputation: 4130

If you use velocity-tools, you can check the ComparisonDateTool.

Upvotes: 2

Related Questions