Year isLeap() method in Java with Examples
The isLeap() method of Year class in Java is used to check if this Year object is a leap year or not according to the proleptic calendar system rules.
A year is a leap year if it has 366 days in it.
According to the proleptic calendar system rules, a year is a Leap year if:
- If it is divisible by 4.
- It is not divisible by 100 but it can be divisible by 400.
Syntax:
public boolean isLeap()
Parameter: This method does not accepts any parameter.
Return Value: It returns a boolean True value if this Year object’s value is a leap year according to the proleptic calendar system rules, otherwise it returns False.
Below programs illustrate the isLeap() method of Year in Java:
Program 1:
// Program to illustrate the isLeap() method import java.util.*; import java.time.*; public class GfG { public static void main(String[] args) { // Create first Year object Year firstYear = Year.of(2016); // Check if this year object's value is // a leap year or not System.out.println(firstYear.isLeap()); } } |
true
Program 2:
// Program to illustrate the isLeap() method import java.util.*; import java.time.*; public class GfG { public static void main(String[] args) { // Create first Year object Year firstYear = Year.of(1990); // Check if this year object's value is // a leap year or not System.out.println(firstYear.isLeap()); } } |
false
Reference: https://docs.oracle.com/javase/8/docs/api/java/time/Year.html#isLeap–
Recommended Posts:
- Year of() method in Java with Examples
- Year get() method in Java with Examples
- Year from() Method in Java with Examples
- Year until() Method in Java with Examples
- Year with() Method in Java with Examples
- Year now() method in Java with examples
- Year length() method in Java with Examples
- Year getLong() method in Java with Examples
- Year isAfter() method in Java with Examples
- Year isBefore() method in Java with Examples
- Year plus(TemporalAmount) method in Java with Examples
- Year query() Method in Java with Examples
- Year format() method in Java with Examples
- Year minusYears() method in Java with Examples
- Year range() method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

