Java Leap Year Check isLeapYear(final int year)

Here you can find the source of isLeapYear(final int year)

Description

Determines if the supplied year is a leap year

License

Open Source License

Parameter

Parameter Description
year integer based year (ex. 2000, 2011)

Return

true if the given year is a leap year

Declaration

public static boolean isLeapYear(final int year) 

Method Source Code

//package com.java2s;
/*//from  w ww . j a v a  2  s.co m
 * jGnash, a personal finance application
 * Copyright (C) 2001-2015 Craig Cavanaugh
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * Determines if the supplied year is a leap year
     *
     * @param year integer based year (ex. 2000, 2011)
     * @return {@code true} if the given year is a leap year
     */
    public static boolean isLeapYear(final int year) {
        boolean isLeapYear;

        isLeapYear = year % 4 == 0;

        isLeapYear = isLeapYear && year % 100 != 0;

        return isLeapYear || year % 400 == 0;
    }
}

Related

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