In my groovy test case below i have certain date objects which later i am formatting using DateUtil.format(calendarObj,"yyyy-MM-dd")
.
But when i print the result, it increments the month by 1.
For Example:
Groovy Code:
def testDate=new GregorianCalendar(2000,1,30);
def testDate1=new GregorianCalendar(2000,1,5);
def testDate2=new GregorianCalendar(2000,4,25);
def testDate3=new GregorianCalendar(2000,6,10);
Output (using System.out.println(DateUtil.format(testDate/1/2/3,"yyyy-MM-dd"))
):
2000-03-01
2000-02-05
2000-05-25
2000-07-10
Can anyone please explain why this is happening.