Java Leap Year Check isLeapYear(int y)

Here you can find the source of isLeapYear(int y)

Description

Check if the given year is leap year.

License

Open Source License

Return

true if the year is a leap year

Declaration

public static boolean isLeapYear(int y) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from   w  ww  .ja  va 2  s.c  o  m
     * Check if the given year is leap year.
     *
     * @return <code>true</code> if the year is a leap year
     */
    public static boolean isLeapYear(int y) {
        boolean result = false;

        if (((y % 4) == 0) && // must be divisible by 4...
                ((y < 1582) || // and either before reform year...
                        ((y % 100) != 0) || // or not a century...
                        ((y % 400) == 0))) { // or a multiple of 400...
            result = true; // for leap year.
        }
        return result;
    }
}

Related

  1. isJulianLeapYear(int normalizedJulianYear)
  2. isLeapYear(final int year)
  3. isLeapYear(final int year)
  4. isLeapYear(int prolepticYear)
  5. isLeapYear(int y)
  6. isLeapYear(int year)
  7. isLeapYear(int year)
  8. isLeapYear(int year)
  9. isLeapYear(int year)