Java Date Time Java Java API
java.time.YearMonth
public YearMonth plusYears(long yearsToAdd)
Returns a copy of this YearMonth with the specified number of years added.
YearMonth
package com.logicbig.example.yearmonth;import java.time.YearMonth;public class PlusYearsExample { public static void main(String... args) { YearMonth y = YearMonth.of(2010, 11); System.out.println(y); YearMonth y2 = y.plusYears(20); System.out.println(y2); YearMonth y3 = y.plusYears(-20); System.out.println(y3); }}
2010-112030-111990-11