Here you can find the source of lastDay(int year, int month)
private static int lastDay(int year, int month) throws java.text.ParseException
//package com.java2s; public class Main { private static int lastDay(int year, int month) throws java.text.ParseException { int day = 0; switch (month) { case 1:// ww w.j ava 2s. co m case 3: case 5: case 7: case 8: case 10: case 12: day = 31; break; case 2: if ((year % 4) == 0) { if ((year % 100) == 0 && (year % 400) != 0) { day = 28; } else { day = 29; } } else { day = 28; } break; default: day = 30; } return day; } }