Could anyone explain how to show last year and next year in a user macro. I tried to subtract and add but was not able to convert the string to an integer before the arithmetic operation
#set ($thisYear = $action.dateFormatter.formatGivenString("yyyy",$content.currentDate) )
#set ($lastYear = $thisYear - 1)
$lastYear
If that code is working and you only need to cast as integer, see if this works: https://stackoverflow.com/questions/2156502/how-to-convert-string-into-integer-in-the-velocity-template
Kind regards,
Thiago Masutti
Hello,
Didn't find it in that post, but this seems to work:
#set($thisYear=$action.dateFormatter.formatGivenString("yyyy",$content.currentDate) )
#set($thisYearInt = $generalUtil.convertToInteger("$thisYear") )
#set($nextYear = $thisYearInt + 1)
$nextYear
-Frithjof
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.