Java Leap Year Check isLeapYear(long year)

Here you can find the source of isLeapYear(long year)

Description

Determines if the specified year is a leap year in the Persian calendar.

License

Open Source License

Parameter

Parameter Description
year the "Persian" year.

Return

true if year is a leap year, false otherwise.

Declaration

public static boolean isLeapYear(long year) 

Method Source Code

//package com.java2s;
/*/*ww  w. j  av a2  s . co  m*/
 PersianCalendarHelper.java
 2005-02-20 21:23:17
 Copyright ? Ghasem Kiani <ghasemkiani@yahoo.com>
    
 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 2 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, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

public class Main {
    /** Array to cache the leap status of each year from year 1 to year 2048 */
    private static final boolean[] LEAP_CACHE = new boolean[2048];
    /** The start year which we cache its leap status */
    private static final int START = 1;

    /**
       Determines if the specified year is a leap year in the Persian calendar.
               
       @param year the "Persian" year.
       @return <code>true</code> if <code>year</code> is a leap year, <code>false</code> otherwise.
     */
    public static boolean isLeapYear(long year) {
        return LEAP_CACHE[(int) (year - START)];
    }
}

Related

  1. isLeapYear(int year)
  2. isLeapYear(int year)
  3. isLeapYear(int year)
  4. isLeapYear(Integer year)
  5. isLeapYear(long year)
  6. isLeapYear(String inputDate)
  7. leapYear(int year)
  8. leapYear(int year)
  9. leapYear(int year)