YearMonth isLeapYear() example

Description

YearMonth isLeapYear() checks if the year is a leap year, according to the ISO proleptic calendar system rules.

Syntax

isLeapYear has the following syntax.


public boolean isLeapYear()

Example

The following example shows how to use isLeapYear.


import java.time.YearMonth;
//from   ww  w  .  j av  a  2  s  .co m
public class Main {
  public static void main(String[] args) {
    YearMonth y = YearMonth.now();

    System.out.println(y.isLeapYear());

  }
}

The code above generates the following result.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset