Java Date Time Java Java API
java.time.LocalDate
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).
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); }}
365366