Re: Velocity and Date Tokens

Not applicable

Velocity and Date Tokens

Hi Nation!

We are working on a velocity script to make a date formatted in a more natural language like "We will expect you on December 13". Unfortunatelly, when I try to use the line 
#set( $mydate = ${convert.parseDate(${lead.mydatetoken},"YYYY-MM-dd")})
The variable $mydate is empty. I realized this has to do with the fact the string is not always YYYY-MM-dd, it can change. I still haven't figured out why, I believe it has to do with the fact that our users have different locales.

My question is... is there a way to get from the actual lead token, in this case ${lead.mydatetoken}, a definitive value regardless of locale? just as you would in other programming languages where you would get a long counting the seconds from midnight January 1st 1970? 

Any help will be very appreciated, thanks!
Tags (1)
Level 10 - Champion Alumni

Re: Velocity and Date Tokens

Why can't you use a text my token that has December 13?
Level 4

Re: Velocity and Date Tokens

Hi Carlos,

Looks to me as if you are getting the vaue from lead correctly.  However, you should using the .toDate() method (if available).

Once you have the date in the object, format it with .format()., java.lang.String, java.lang.Object, java.util.Locale, java.util.TimeZone)

Just piecing this together, as I am looking for a test bed for velocity scripts.
Brennan McAdams