Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Show last year and next year in user macro

frithjof falck
Contributor
May 13, 2022

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

 

1 answer

1 accepted

1 vote
Answer accepted
Thiago Masutti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 13, 2022

Hi @frithjof falck 

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

frithjof falck
Contributor
May 15, 2022

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events