0
votes

I'm using Velocity (integrated within our company's software) to code email templates, however I'm struggling to find a solution for the above.

The software stores a policy start date as the ${POLSDATE} variable, however I need to be able to add 14 days to this date, I've tried the below (among several other variations):

#set ($rendate_14 = $date.toCalendar(${POLSDATE}))
$rendate_14.add(5,14)

"$rendate_14" without the addition prints a comma separated array of data (the date in this example is 01/08/17):

java.util.GregorianCalendar[time=1501585201000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Europe/London",offset=0,dstSavings=3600000,useDaylight=true,transitions=242,lastRule=java.util.SimpleTimeZone[id=Europe/London,offset=0,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]],firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=1,YEAR=2017,MONTH=7,WEEK_OF_YEAR=31,WEEK_OF_MONTH=1,DAY_OF_MONTH=1,DAY_OF_YEAR=213,DAY_OF_WEEK=3,DAY_OF_WEEK_IN_MONTH=1,AM_PM=1,HOUR=0,HOUR_OF_DAY=12,MINUTE=0,SECOND=1,MILLISECOND=0,ZONE_OFFSET=0,DST_OFFSET=3600000]

...however with the addition .add(5,14) it doesn't print any information at all.

Any ideas?

1
My issue was that the output is the "java.util..." bit rather than a formatted date, simply adding $date.format('d MMMM yyyy',$rendate_14) (or similar) resolved the matter!Tom

1 Answers

0
votes

It is very simple: java.util.Calendar#add is a void method,of course print nothing.

Try the following code instead:

#set ($rendate_14 = $date.toCalendar(${POLSDATE}))
$rendate_14.add(5,14)
$rendate_14