Returns a copy of this LocalDateTime with the specified number of months added.
package com.logicbig.example.localdatetime;
import java.time.LocalDateTime;
import java.time.Month;
public class PlusMonthsExample {
public static void main (String... args) {
LocalDateTime d = LocalDateTime.of(2016, Month.APRIL, 1,
22, 20, 30);
LocalDateTime d2 = d.plusMonths(100);
System.out.println(d2);
d2 = d.plusMonths(-100);
System.out.println(d2);
}
}
Output
2024-08-01T22:20:30
2007-12-01T22:20:30