Java Date Time Java Java API
java.time.YearMonth
public int getYear()
Returns the year field of this YearMonth object
package com.logicbig.example.yearmonth;import java.time.YearMonth;public class GetYearExample { public static void main(String... args) { YearMonth y = YearMonth.of(2010, 11); System.out.println(y); int year = y.getYear(); System.out.println(year); }}
2010-112010