2013年10月4日 星期五

java-date last date of the month

java=last-date-of-month


// Create a calendar object and set year and moth
Calendar mycal = new GregorianCalendar(1999, Calendar.FEBRUARY, 1);
// Get the number of days in that month
int daysInMonth = mycal.getActualMaximum(Calendar.DAY_OF_MONTH); // 28
// Try month in a leap year
mycal = new GregorianCalendar(2000, Calendar.FEBRUARY, 1);
daysInMonth= mycal.getActualMaximum(Calendar.DAY_OF_MONTH);     // 29

沒有留言:

張貼留言