velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Bubna" <>
Subject Re: Date formatting from a string
Date Wed, 20 Jun 2007 21:11:22 GMT
Use the NumberTool to convert it to a Number, then use the DateTool to
convert that to a Date:

#set( $myMillisAsNumber = $number.toNumber($myMillisAsString) )
#set( $myMillisAsDate = $date.toDate($myMillisAsNumber) )

or you can always extend the DateTool and add your own method to do it directly.

On 6/20/07, Jason Mansfield <> wrote:
> Hi,
> I am trying to format a string that contains a date as a number of milliseconds since
1970 (in text format) in my velocity template.
> I realise that it should be a long, but in this instance we have to deal with the number
being represented as a string.
> Is there a way of converting the string representation into a date using either DateTools
or other Java object methods?
> Many thanks
> Jason

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message