Java Leap Year Check isLeapYear(int year)

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

Description

is Leap Year

License

Apache License

Declaration

public static boolean isLeapYear(int year) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Calendar;

public class Main {

    public static boolean isLeapYear(int year) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(year, 2, 1);//  www. j  a  va  2  s  .  co  m
        calendar.add(Calendar.DATE, -1);
        if (calendar.get(Calendar.DAY_OF_MONTH) == 29) {
            System.out.println(year + " year is a leap year.");
            return true;
        } else {
            System.out.println(year + " year is not a leap year.");
            return false;
        }
    }
}

Related

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