LIFERAYに乗っかっているVelocityで現在時刻取得する方法のメモです。

LIFERAYのVelocityVariablesで定義されているdateUtilクラスを利用します。
そして、dateUtilクラスの戻り値に対してgetCurrentDateメソッドを利用して取得できます。


##現在時間を取得
#set ($date = $dateUtil)
#set ($currentTime = $date.getCurrentDate("yyyy.MM.dd HH:mm:ss", $locale))
<p>現在時刻:$currentTime</p>
 

これを実行すると以下のような結果が返ってきます。
現在時刻:2009.08.31 18:49:37

getCurrentDateの第1引数は任意の形式で設定してOKです。

参考:Init Example - Wiki - Liferayの下の方