Here you can find the source of getLastDayOfMonth(int year, int month)
public static int getLastDayOfMonth(int year, int month)
//package com.java2s; //License from project: Open Source License public class Main { public static int getLastDayOfMonth(int year, int month) { if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) { return 31; }//from w ww . j a v a 2 s .co m if (month == 4 || month == 6 || month == 9 || month == 11) { return 30; } if (month == 2) { if (isLeapYear(year)) { return 29; } else { return 28; } } return 0; } public static boolean isLeapYear(int year) { return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); } }