#set( $dateOptions = {
"formats" : {
"userin" : "yyyy-MM-dd",
"userout" : "MMMM d, yyyy"
},
"timezones" : {
"userin" : "America/New_York",
"userout" : "America/New_York"
},
"locale" : $date.getLocale()
} )
#set( $expirationDatelike = $lead.ExpirationDate )
#set( $expirationDate = $convert.parseDate(
$expirationDatelike,
$dateOptions.formats.userin,
$dateOptions.locale,
$date.getTimeZone().getTimeZone($dateOptions.timezones.userin)
) )
#set( $expirationDate_formatted = $date.format(
$dateOptions.formats.userout,
$expirationDate,
$dateOptions.locale,
$date.getTimeZone().getTimeZone($dateOptions.timezones.userout)
) )
${expirationDate_formatted}
Note the very important inclusion of time zones (set the userin and userout time zone strings according to your tz).
You'll see a lot of examples (frankly, any examples that weren't originally contributed by yours truly) that are broken because they are timezone-unaware. Those examples may seem simpler, but they're broken.