YearMonth isLeapYear() method in Java with Examples
The isLeapYear() method of YearMonth class in Java is used to check if the year in this YearMonth object is a leap year or not.
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 isLeapYear()
Parameter: This method does not accepts any parameter.
Return Value: It returns a boolean True value if the value of year in this YearMonth object is a leap year according to the proleptic calendar system rules, otherwise it returns False.
Below programs illustrate the isLeapYear() method of YearMonth 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 YearMonth object YearMonth yearMonth = YearMonth.of(2016, 2); // Check if year in this YearMonth object's // value is a leap year or not System.out.println(yearMonth.isLeapYear()); } } |
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 YearMonth object YearMonth yearMonth = YearMonth.of(1990, 2); // Check if year in this YearMonth object's // value is a leap year or not System.out.println(yearMonth.isLeapYear()); } } |
false
Reference: https://docs.oracle.com/javase/8/docs/api/java/time/YearMonth.html#isLeapYear–
Recommended Posts:
- LocalDate isLeapYear() method in Java with Examples
- ChronoLocalDate isLeapYear() method in Java with Examples
- YearMonth until() Method in Java with Examples
- YearMonth with() Method in Java with Examples
- YearMonth isValidDay() method in Java with Examples
- YearMonth withYear() method in Java with Examples
- YearMonth isAfter() method in Java with Examples
- YearMonth query() Method in Java with Examples
- YearMonth isBefore() method in Java with Examples
- YearMonth range() method in Java with Examples
- YearMonth withMonth() method in Java with Examples
- YearMonth plus(TemporalAmount) method in Java with Examples
- YearMonth lengthOfYear() method in Java with Examples
- YearMonth isSupported(TemporalField) method in Java with Examples
- YearMonth isSupported(TemporalUnit) 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.


