package com.logicbig.example.offsetdatetime;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
public class PlusYearsExample {
public static void main(String... args) {
OffsetDateTime d = OffsetDateTime.of(2016, 11, 15, 18,
20, 30, 100, ZoneOffset.ofHours(-6));
OffsetDateTime d2 = d.plusYears(30);
System.out.println(d2);
OffsetDateTime d3 = d.plusYears(-10);
System.out.println(d3);
}
}
Output
2046-11-15T18:20:30.000000100-06:00
2006-11-15T18:20:30.000000100-06:00