Using $dateTool.toDate in a Velocity template does not return any date


  • In a Velocity template, trying to get a date using dateTool.toDate does not work as expected when using a locale different from default one.
  • As an example, if under those conditions we have a Velocity template with below code 
#set ($dateStr = $dateTool.toDate( "EEE, dd MMM yyyy hh:mm:ss Z" , $

Date: $dateStr
  • Instead of seeing the expected date, we'll just see how the name of variable $dateStr is printed.


  • Liferay Portal 6.2


  • Using $reserved-article-display-date.getData() helps to avoid this situation since it returns a String with default locale, so we just need, as well, to indicate to dateTool which is such default locale in order to properly deal with our date.
  • Below code can solve the issue:
#set ($dateStr = $dateTool.toDate( "EEE, dd MMM yyyy hh:mm:ss Z" , $reserved-article-display-date.getData(), $localeUtil.getDefault())

Date: $dateStr

Additional Information


¿Fue útil este artículo?
Usuarios a los que les pareció útil: 0 de 0