Java has months from 0, so June 5th. Always use constants. Therefore, I would write:
Calendar cal = new GregorianCalendar(2010, Calendar.MAY, 31);
The same goes for printing your calendar. If you do cal.get(Calendar.MONTH), you get the value 6, JULY.
source
share