Returns a copy of this LocalDateTime with the specified number of years added.
package com.logicbig.example.localdatetime;
import java.time.LocalDateTime;
import java.time.Month;
public class PlusYearsExample {
public static void main (String... args) {
LocalDateTime d = LocalDateTime.of(2016, Month.APRIL, 1,
22, 20, 30, 500000);
LocalDateTime d2 = d.plusYears(20);
System.out.println(d2);
d2 = d.plusYears(-20);
System.out.println(d2);
}
}
Output
2036-04-01T22:20:30.000500
1996-04-01T22:20:30.000500