YearMonth lengthOfYear() example

Description

YearMonth lengthOfYear() returns the length of the year.

This returns the length of the year in days, either 365 or 366.

Syntax

lengthOfYear has the following syntax.


public int lengthOfYear()

Example

The following example shows how to use lengthOfYear.


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

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

  }
}

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