Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String to Date with convert

Tags:

velocity

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,

like image 972
Ale Avatar asked Jan 12 '23 02:01

Ale


2 Answers

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 
like image 156
Harsh Avatar answered Mar 08 '23 05:03

Harsh


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

like image 21
Ale Avatar answered Mar 08 '23 05:03

Ale