Nipun Bahr wrote:
Hi Paul,
If I am printing startCal and endCal values after incrementing, its giving me April 30 and may 24 respectively-
Date currentDate = new Date();
Calendar startCal = Calendar.getInstance();
Calendar endCal = Calendar.getInstance();
startCal.setTime(currentDate);
startCal.add(Calendar.DATE,12);
System.out.println(startCal);
endCal.setTime(currentDate);
endCal.add(Calendar.DATE,37);
System.out.println(endCal);
Hi All,
First of all sorry for late reply
When I run the above code snippet, I got the output as-
java.util.GregorianCalendar[time=1306951576296,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT+05:30",offset=19800000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2011,MONTH=5,WEEK_OF_YEAR=23,WEEK_OF_MONTH=1,DAY_OF_MONTH=1,DAY_OF_YEAR=152,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=1,AM_PM=1,HOUR=11,HOUR_OF_DAY=23,MINUTE=36,SECOND=16,MILLISECOND=296,ZONE_OFFSET=19800000,DST_OFFSET=0]
java.util.GregorianCalendar[time=1309111576296,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT+05:30",offset=19800000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2011,MONTH=5,WEEK_OF_YEAR=27,WEEK_OF_MONTH=5,DAY_OF_MONTH=26,DAY_OF_YEAR=177,DAY_OF_WEEK=1,DAY_OF_WEEK_IN_MONTH=4,AM_PM=1,HOUR=11,HOUR_OF_DAY=23,MINUTE=36,SECOND=16,MILLISECOND=296,ZONE_OFFSET=19800000,DST_OFFSET=0
If I look inside this output it gives me Day of the month=1, month=5
and Day of the month=26, month=5 respectively
which does not fit according to today's date i.e may 20th.
How come its correct??
should not it give 1 June and 26 June respectively considering today's date as 20 May??