OffsetDateTime plusYears(long years)
returns a copy of this OffsetDateTime with the specified
period in years added.
plusYears
has the following syntax.
public OffsetDateTime plusYears(long years)
The following example shows how to use plusYears
.
import java.time.OffsetDateTime; public class Main { public static void main(String[] args) { OffsetDateTime o = OffsetDateTime.now(); OffsetDateTime d = o.plusYears(20); System.out.println(d); } }
The code above generates the following result.