30 days hath September, April, June and November, All the rest have 31, Excepting February alone (And that has 28 days clear, With 29 in each leap year). <
Calendar cal = Calendar.getInstance(); cal.set(Calendar.MONTH, yourMonth); cal.set(Calendar.YEAR, yourYear); cal.getActualMaximum(Calendar.DAY_OF_MONTH); // <-- the result!