Velocity: month (of date) in local language | Community
Skip to main content
New Participant
October 11, 2021
Solved

Velocity: month (of date) in local language

  • October 11, 2021
  • 1 reply
  • 2314 views

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

 

  

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

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

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
October 11, 2021

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 )}
rpaauwAuthor
New Participant
October 13, 2021

Thanks Sanford, this helps me out!