Here you can find the source of isValid(int year, int month, int day)
public static boolean isValid(int year, int month, int day)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.GregorianCalendar; public class Main { public static boolean isValid(int year, int month, int day) { if (month > 0 && month < 13 && day > 0 && day < 32) { // month of calendar is 0-based int mon = month - 1; Calendar calendar = new GregorianCalendar(year, mon, day); if (calendar.get(Calendar.YEAR) == year && calendar.get(Calendar.MONTH) == mon && calendar.get(Calendar.DAY_OF_MONTH) == day) { return true; }/* ww w.j ava2 s . c o m*/ } return false; } }