Forum Discussion
Aaronliu
14 years agoFrequent Contributor
not sure what's your test scenario? here show a simple example to you:
import java.text.SimpleDateFormat
String str = "2019-10-18"
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd")
Date d = df.parse(str)
Calendar cal = new GregorianCalendar()
cal.setTime(d)
cal.add(Calendar.YEAR,-2)
def a = cal.getTime()
def c = a.format("yyyy-MM-dd")
log.info c