Close

Java Date Time - YearMonth.isLeapYear() Examples

Java Date Time Java Java API 


Class:

java.time.YearMonth

java.lang.Objectjava.lang.Objectjava.time.YearMonthjava.time.YearMonthjava.time.temporal.TemporalTemporaljava.time.temporal.TemporalAdjusterTemporalAdjusterjava.lang.ComparableComparablejava.io.SerializableSerializableLogicBig

Method:

public boolean isLeapYear()

Checks if the year field of this YearMonth object is a leap year.


Examples


package com.logicbig.example.yearmonth;

import java.time.YearMonth;

public class IsLeapYearExample {

public static void main(String... args) {
YearMonth y = YearMonth.of(2017, 3);
System.out.println(y);

boolean b = y.isLeapYear();
System.out.println(b);

YearMonth y2 = YearMonth.of(2008, 11);
System.out.println(y2);
boolean b2 = y2.isLeapYear();
System.out.println(b2);
}
}

Output

2017-03
false
2008-11
true




See Also