Here you can find the source of getMonthLength(int year, int m)
public static int getMonthLength(int year, int m)
//package com.java2s; public class Main { private static final int[] MONTH_LENGTH = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; private static final int[] LEAP_MONTH_LENGTH = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; public static int getMonthLength(int year, int m) { if ((m < 1) || (m > 12)) { return -1; }//from w ww.j av a2 s. c o m if (isLeapYear(year)) { return LEAP_MONTH_LENGTH[m]; } return MONTH_LENGTH[m]; } public static boolean isLeapYear(int y) { boolean result = false; if (((y % 4) == 0) && // must be divisible by 4... ((y < 1582) || // and either before reform year... ((y % 100) != 0) || // or not a century... ((y % 400) == 0))) { // or a multiple of 400... result = true; // for leap year. } return result; } }