I have read a good post of @SanfordWhiteman regarding showing dates in all kind of ways in emails. In our instance we send emails in 3 different languages (English, German and Dutch). As I am new to Velocity scripting, I'm trying, without success yet, to show the month of the date in the correct language.
I would like to show October in the Dutch language (= oktober) for example. This should be done through a DateTool request, but a cannot figure out how. Does anyone know?
#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("Europe/Amsterdam") )
#set( $defaultLocale = $date.getLocale() )
#set( $calNow = $date.getCalendar() )
#set( $ret = $calNow.setTimeZone($defaultTimeZone) )
#set( $calConst = $field.in($calNow) )
#set( $ISO8601DateOnly = "yyyy-MM-dd" )
#set( $ISO8601DateTime = "yyyy-MM-dd'T'HH:mm:ss" )
#set( $ISO8601DateTimeWithSpace = "yyyy-MM-dd HH:mm:ss" )
#set( $ISO8601DateTimeWithMillisUTC = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" )
#set( $ISO8601DateTimeWithMillisTZ = "yyyy-MM-dd'T'HH:mm:ss.SSSZ" )
${date.format(
"d MMMM yyyy",
$calNow,
$defaultLocale,
$defaultTimeZone
)}
Solved! Go to Solution.
Right now you haven’t done anything to change the locale.
You have to instantiate a new locale object:
#set( $leadLocale = $convert.toLocale("nl_NL") )
Then you can use it:
${date.format(
"d MMMM yyyy",
$calNow,
$leadLocale,
$defaultTimeZone
)}
Right now you haven’t done anything to change the locale.
You have to instantiate a new locale object:
#set( $leadLocale = $convert.toLocale("nl_NL") )
Then you can use it:
${date.format(
"d MMMM yyyy",
$calNow,
$leadLocale,
$defaultTimeZone
)}
Thanks Sanford, this helps me out!