Calendar calendar = Calendar.getInstance(); calendar.set(2010, 4, 10); System.out.println(calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); System.out.println(calendar.get(Calendar.DAY_OF_MONTH));
It's weird thing calendar.set(2010, 4, 10), actually set date as May 10, 2010. "4" for the MONTH field is really misleading. It sets Month as "May".
caalendar.getActualMaximum() calculates the maximum of days in month of May.
So output should be:
31
10
No comments:
Post a Comment