2014-03-03 37 views
1

我想小費,請:字符串與轉換日期

將字符串轉換爲日期的速度:

這是$convert.parseDate($currentMessage.date.begin)

我嘗試過:

#set($str = $!currentMessage.date.begin) 
$str 
#set($dateTransforme = $date.toDate('yyyy-MM-dd', $date.date)) 
$dateTransforme 

$dateTransforme.parseDate($str) <br /> 

NB $ currentMessage.date.begin是一個字符串。

我繼續有在運行:

$ dateTransforme.parseDate($ STR)

爲什麼?我的字符串格式爲 '2014年2月26日'

感謝,

回答

2

這裏是工作的代碼與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 
+0

謝謝哥們! – Ale

+0

@Ale,非常歡迎。如果它符合你的目的,請給我並接受這個答案。 – Harsh

+0

哦...完成了,我認爲現在沒問題......很快見到你。 – Ale

1

最後,這是確定的:

## 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)) 

啤酒

2

將字符串轉換爲日期對象

#set($dateObj = $date.toDate("dd/MM/yyyy", "08/09/2015")) 

將日期對象格式化爲「yyyy-MM-dd」

#set($dateFormated = $date.format("yyyy-MM-dd", $dateObj))