掲示板
velocity templates and dates
17年前 に Scott McMasters によって更新されました。
velocity templates and dates
New Member 投稿: 23 参加年月日: 06/12/04 最新の投稿
I need to be able to format dates in journal entries (such as $reserved-article-display-date) but velocity's DateTool isn't available. I don't know much about velocity. Anyone know offhand how I can do this easily?
Thanks,
Scott
Thanks,
Scott
16年前 に alfonso lopez によって更新されました。
RE: velocity templates and dates
Regular Member 投稿: 132 参加年月日: 07/04/25 最新の投稿
Did you solve it?
15年前 に Rasto Rehak によって更新されました。
RE: velocity templates and dates
Junior Member 投稿: 66 参加年月日: 07/03/08 最新の投稿
Yes, I did.
$dateTool.format( 'full','short', $dateTool.toDate( "EEE, dd MMM yyyy hh:mm:ss Z" , $reserved-article-display-date.getData()) , $localeUtil.fromLanguageId( $request.locale ) )
$dateTool.format( 'full','short', $dateTool.toDate( "EEE, dd MMM yyyy hh:mm:ss Z" , $reserved-article-display-date.getData()) , $localeUtil.fromLanguageId( $request.locale ) )
15年前 に Milan Jaroš によって更新されました。
RE: velocity templates and dates
Expert 投稿: 268 参加年月日: 08/08/18 最新の投稿
Thank you so much.
is it possible to use just
It's working but I don't know if it is correct.
If you want to display date in another format you can use this:
(for more info see DateTool Velocity Documentation)
is it possible to use just
$locale
instead of $localeUtil.fromLanguageId( $request.locale )
? It's working but I don't know if it is correct.
If you want to display date in another format you can use this:
$dateTool.format("dd. MM. yyyy / hh.mm:ss",
$dateTool.toDate("EEE, dd MMM yyyy hh:mm:ss Z",
$reserved-article-modified-date.getData()), $locale)
(for more info see DateTool Velocity Documentation)
12年前 に David García González によって更新されました。
RE: velocity templates and dates
Regular Member 投稿: 127 参加年月日: 09/07/14 最新の投稿
Yes, you can use DateTool
http://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/generic/DateTool.html
For example to get the actual year:
http://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/generic/DateTool.html
For example to get the actual year:
$dateTool.get('yyyy')
12年前 に Sami Laribi によって更新されました。
RE: velocity templates and dates
New Member 投稿: 1 参加年月日: 11/07/15 最新の投稿
dateTool.toDate() doesn't work for me (Liferay 6.0.6CE - maybe solved in 6.1) when applied to $reserved-article-modified-date.
This things however works fine (using Liferay parsing library instead of velocity's one):
It converts "Thu, 14 Jul 2011 14:47:32 +0000" into "14 juil. 2011 à 14:47:32" (french).
This things however works fine (using Liferay parsing library instead of velocity's one):
#set ($portalBeanLocator = $portal.getClass().forName('com.liferay.portal.kernel.bean.PortalBeanLocatorUtil'))
#set ($dateFormatFactory = $portalBeanLocator.locate('com.liferay.portal.kernel.util.DateFormatFactoryUtil'))
#set ($indexFormat = $dateFormatFactory.getSimpleDateFormat('EEE, dd MMM yyyy hh:mm:ss Z'))
#set ($modified_date = $indexFormat.parse($reserved-article-modified-date.getData()))
$dateTool.format("dd MMM yyyy 'à' HH:mm:ss",$modified_date)
It converts "Thu, 14 Jul 2011 14:47:32 +0000" into "14 juil. 2011 à 14:47:32" (french).
13年前 に Josemar Salles によって更新されました。
RE: velocity templates and dates
New Member 投稿: 12 参加年月日: 10/10/29 最新の投稿
Hi Scott,
did you solve your problem about formatting?
I have the same question.
Thank you.
did you solve your problem about formatting?
I have the same question.
Thank you.
13年前 に Milan Jaroš によって更新されました。