Here is the working code with datetool
#set ($toDateRegDate= $dateTool.toDate('yyyy-MM-dd hh:mm:ss Z', $Video.Date.getData()))
#set ($videoDate = $dateTool.format('MMMM dd,yyyy', $toDateRegDate,$locale))
$videoDate
Question
I would like a tip, please :
To convert a String to Date in velocity:
It is $convert.parseDate($currentMessage.date.begin)
I try too :
#set($str = $!currentMessage.date.begin)
$str
#set($dateTransforme = $date.toDate('yyyy-MM-dd', $date.date))
$dateTransforme
$dateTransforme.parseDate($str) <br />
N.B. $currentMessage.date.begin is a string.
I continue to have at the running :
$dateTransforme.parseDate($str)
Why? My string is in the format '2014-02-26'
Thanks,
Solution
Here is the working code with datetool
#set ($toDateRegDate= $dateTool.toDate('yyyy-MM-dd hh:mm:ss Z', $Video.Date.getData()))
#set ($videoDate = $dateTool.format('MMMM dd,yyyy', $toDateRegDate,$locale))
$videoDate
OTHER TIPS
Finally, It's OK:
## tranformation of the data to dates : date.begin
#set($dateBegin = $date.toDate('yyyy-MM-dd',$!currentMessage.date.begin))
## tranformation of the data to dates : date.end
#set($dateEnd = $date.toDate('yyyy-MM-dd',$!currentMessage.date.end))
Ale
Convert a string to a date object
#set($dateObj = $date.toDate("dd/MM/yyyy", "08/09/2015"))
Format the date objet to "yyyy-MM-dd"
#set( $dateFormated = $date.format("yyyy-MM-dd", $dateObj))