I pieced this script together from some existing scripts in my instance and from some posts I found here and on blogs, but when I preview the email, the date ends up having a space at the end. Is this an issue with the script? Or is the script working correctly and the field value itself has the extra space the culprit?
#set( $dateOptions = {
"fieldValue" : $o.Application_Deadline__c,
"formats" : {
"in" : "yyyy-MM-dd",
"out" : "MMMM d, yyyy"
},
"timezones" : {
"in" : "America/New_York",
"out" : "America/New_York"
},
"locale" : $date.getLocale()
} )
## ---- No need to change anything below this line! ----
#set( $dateOptions.timezones.in = $date.getTimeZone().getTimeZone($dateOptions.timezones.in) )
#set( $dateOptions.timezones.out = $date.getTimeZone().getTimeZone($dateOptions.timezones.out) )
#set( $inDate = $convert.parseDate($dateOptions.fieldValue, $dateOptions.formats.in, $dateOptions.locale, $dateOptions.timezones.in) )
${date.format($dateOptions.formats.out, $inDate, $dateOptions.locale, $dateOptions.timezones.out)}
#end
#end
Solved! Go to Solution.
Velocity is strictly space-preserving, so it sounds like the line break is actually what you're seeing as a space.
Try this instead:
${date.format($dateOptions.formats.out, $inDate, $dateOptions.locale, $dateOptions.timezones.out)}##
Please highlight the code (as Java, the closest to Velocity) using the Advanced Editor's Syntax Highlighter, then we'll continue.
Updated and highlighted the code
Velocity is strictly space-preserving, so it sounds like the line break is actually what you're seeing as a space.
Try this instead:
${date.format($dateOptions.formats.out, $inDate, $dateOptions.locale, $dateOptions.timezones.out)}##
That worked! Thanks!