Here you can find the source of daysInMonth(int year, int month)
private static int daysInMonth(int year, int month)
//package com.java2s; //License from project: Apache License public class Main { private static int daysInMonth(int year, int month) { int daysInMonth; switch (month) { case 1://from w w w . ja va 2s. c o m case 3: case 5: case 7: case 8: case 10: case 12: daysInMonth = 31; break; case 2: if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) { daysInMonth = 29; } else { daysInMonth = 28; } break; default: // returns 30 even for nonexistant months daysInMonth = 30; } return daysInMonth; } }