Close

Java Date Time - LocalDate.lengthOfYear() Examples

Java Date Time Java Java API 


Class:

java.time.LocalDate

java.lang.Objectjava.lang.Objectjava.time.LocalDatejava.time.LocalDatejava.time.temporal.TemporalTemporaljava.time.temporal.TemporalAdjusterTemporalAdjusterjava.time.chrono.ChronoLocalDateChronoLocalDatejava.io.SerializableSerializableLogicBig

Method:

public int lengthOfYear()

This method returns the number of days in the year corresponding to this local date. It will be either 365 (normal year) or 366 (leap year).


Examples


package com.logicbig.example.localdate;

import java.time.LocalDate;

public class LengthOfYearExample {

public static void main (String... args) {
LocalDate d = LocalDate.of(1999, 5, 3);
int i = d.lengthOfYear();
System.out.println(i);

LocalDate d2 = LocalDate.of(2000, 5, 3);
int i2 = d2.lengthOfYear();
System.out.println(i2);
}


}

Output

365
366




See Also