Java Date Time - LocalDate lengthOfYear() example








LocalDate lengthOfYear() returns the length of the year represented by this date. 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.LocalDate;

public class Main {
  public static void main(String[] args) {
    LocalDate a = LocalDate.of(2014, 6, 30);

    System.out.println(a.lengthOfYear());
  }
}

The code above generates the following result.