Java Date Time Java Java API
java.time.YearMonth
public YearMonth withYear(int year)
Returns a copy of this YearMonth with year field replaced with the specified year value.
YearMonth
package com.logicbig.example.yearmonth;import java.time.YearMonth;public class WithYearExample { public static void main(String... args) { YearMonth y = YearMonth.of(2010, 11); System.out.println(y); YearMonth y2 = y.withYear(1980); System.out.println(y2); }}
2010-111980-11