Java Date Time Java Java API
java.time.YearMonth
public int lengthOfYear()
Returns the length of the year of this YearMonth object, either 365 or 366, depending on the leap year.
package com.logicbig.example.yearmonth;import java.time.YearMonth;public class LengthOfYearExample { public static void main(String... args) { YearMonth y = YearMonth.of(2010, 11); System.out.println(y); int l = y.lengthOfYear(); System.out.println(l); YearMonth y2 = YearMonth.of(2020, 11); System.out.println(y2); int l2 = y2.lengthOfYear(); System.out.println(l2); }}
2010-113652020-11366