Here you can find the source of getMaxDayOfMonth(int year, int month)
public static int getMaxDayOfMonth(int year, int month)
//package com.java2s; import java.util.Calendar; import java.util.GregorianCalendar; public class Main { private static final int[] DAY_OF_MONTH = new int[] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; public static int getMaxDayOfMonth(int year, int month) { if (month == 1 && isLeapYear(year)) { return 29; }/*from w ww . j a va 2 s. c o m*/ return DAY_OF_MONTH[month]; } public static boolean isLeapYear(int year) { Calendar calendar = Calendar.getInstance(); return ((GregorianCalendar) calendar).isLeapYear(year); } }