Duration addTo(Temporal temporal) example
Description
Duration addTo(Temporal temporal)
adds this duration
to the specified temporal object.
Syntax
addTo
has the following syntax.
public Temporal addTo(Temporal temporal)
Example
The following example shows how to use addTo
.
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.temporal.Temporal;
/* w ww.ja va 2 s .c o m*/
public class Main {
public static void main(String[] args) {
Duration duration = Duration.ofDays(2);
Temporal l = duration.addTo(LocalDateTime.now());
System.out.println(l);
}
}
The code above generates the following result.