Here you can find the source of maxDayOfMonth(int year, int month)
public static int maxDayOfMonth(int year, int month)
//package com.java2s; public class Main { public static int maxDayOfMonth(int year, int month) { if (month <= 0 || month > 12) { return -1; }//from ww w . java 2s.co m int day = 0; switch (month) { case 2: day = 28; break; case 4: case 6: case 9: case 11: day = 30; break; default: day = 31; } if (month == 2 && isLeapYear(year)) { day++; } return day; } public static boolean isLeapYear(int year) { return (year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0)); } }