Online Java Compiler By
JavaTpoint.com
import java.time.*; public class YearMonthExample4 { public static void main(String[] args) { YearMonth ym1 = YearMonth.now(); YearMonth ym2 = ym1.plus(Period.ofYears(2)); System.out.println(ym2); } }
Output