Java Date Time Java Java API
java.time.Year
public int length()
Returns the length of this year in days, 365 or 366 depending on leap year.
package com.logicbig.example.year;import java.time.Year;public class LengthExample { public static void main(String... args) { Year y = Year.of(2011); System.out.println(y); int l = y.length(); System.out.println(l); Year y2 = Year.of(2020); System.out.println(y2); int l2 = y2.length(); System.out.println(l2); }}
20113652020366