Java Utililty Methods Leap Year Check

List of utility methods to do Leap Year Check

Description

The list of methods to do Leap Year Check are organized into topic(s).

Method

booleanisLeapYear(int year)
return the leap year for years 1581-8999.
if (year < 1000)
    throw new IllegalArgumentException("year must be four-digits");
return (year % 4) == 0 && (year % 100 != 0 || year % 400 == 0);
booleanisLeapYear(int year)
is Leap Year
boolean isLeapYear = false;
if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
    isLeapYear = true;
return isLeapYear;
booleanisLeapYear(int year)
is Leap Year
Calendar calendar = Calendar.getInstance();
return ((GregorianCalendar) calendar).isLeapYear(year);
booleanisLeapYear(Integer year)
is Leap Year
boolean result = false;
if (year % 100 == 0) {
    if (year % 400 == 0) {
        result = true;
} else if (year % 4 == 0) {
    result = true;
return result;
booleanisLeapYear(long year)
Gets if a year is a leap year
return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
booleanisLeapYear(long year)
Determines if the specified year is a leap year in the Persian calendar.
return LEAP_CACHE[(int) (year - START)];
booleanisLeapYear(String inputDate)
is Leap Year
return isLeapYear(Integer.parseInt(inputDate.substring(0, 4)));
booleanleapYear(int year)
leap Year
return year % 4 == 0 && year % 400 == 0;
booleanleapYear(int year)
leap Year
boolean leap;
if (year % 4 == 0) {
    if (year % 100 == 0) {
        if (year % 400 == 0)
            leap = true;
        else
            leap = false;
    } else
...
booleanleapYear(int year)
leap Year
if (year < 4) {
    return false;
return (year % 400 == 0) || (year % 100 != 0 && year % 4 == 0);