0

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.

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
Crudler
  • 2,194
  • 3
  • 30
  • 57

2 Answers2

1

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

Jonathon Rossi
  • 4,149
  • 1
  • 22
  • 32
0

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>
pageman
  • 2,864
  • 1
  • 29
  • 38
  • thanks, but didnt really answer why there isn't a DateTool, but it is a nudge in the right directuion. thanks – Crudler Jun 24 '14 at 07:50
  • @Crudler as per Daniel Hölbling's and Jonathon Rossi's answer you can use .ToString("...") :) – pageman Jun 24 '14 at 10:35