Java Date Time Java Java API
java.time.YearMonth
public boolean isLeapYear()
Checks if the year field of this YearMonth object is a leap year.
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); }}
2017-03false2008-11true