Unable to find DateTool

329 Views Asked by At

in Java velocity, in order to format dates I just add the date tool to the context e.g.

context.add("date", new DateTool());

and then inside the template

$date.format('EEE, MMM d, yyyy at ha', $myDate)

but in NVelocity I am unable to find the DateTool, it doesnt seem to be part of the library.

2

There are 2 best solutions below

0
Jonathon Rossi On BEST ANSWER

You should be able to call .ToString("...") on any System.DateTime.

2
pageman On

a search for anything mentioning "date" in http://nvelocity.sourceforge.net yields:

http://nvelocity.sourceforge.net/api/NVelocity/App/Tools/VelocityFormatter.html

and

http://nvelocity.sourceforge.net/api/NVelocity/SupportClass.html

you might want to reference the following post:

Refer the above link and make simple thing like below in .vm template,

#set ($recordDate = $RecordCreationDate.ToString("dd-MMM-yyyy") )
<div> $recordDate </div>