OffsetDateTime plus(long amountToAdd, TemporalUnit unit) example
Description
OffsetDateTime plus(long amountToAdd, TemporalUnit unit)
returns a copy of this date-time with the specified amount added.
Syntax
plus
has the following syntax.
public OffsetDateTime plus(long amountToAdd, TemporalUnit unit)
Example
The following example shows how to use plus
.
import java.time.OffsetDateTime;
import java.time.temporal.ChronoUnit;
/*w w w.ja v a2 s. c om*/
public class Main {
public static void main(String[] args) {
OffsetDateTime o = OffsetDateTime.now();
OffsetDateTime d = o.plus(20,ChronoUnit.HOURS);
System.out.println(d);
}
}
The code above generates the following result.