posted 23 years ago
I am getting a Calendar representing today - March 1st, 2001 and rolling it back one day. I am not ending up with Feb 28th, but March 31st. This has worked in changing from January to Fevruary, but now I am having this problem. I read in the API that GregorianCalendar should resolve this issue, but I saw the same results - March 31st, 2001.
Any thoughts on how to fix this? Besides writing code to handle February?
GregorianCalendar newCal = new GregorianCalendar();
System.out.println("Todays calendar date:" + getStringFromCalendar(newCal));
//roll back the number of days between the dates passed in
newCal.roll(Calendar.DATE, -1);
System.out.println("After rollback New calendar date:" + getStringFromCalendar(newCal));