Period addTo(Temporal temporal) example
Description
Period addTo(Temporal temporal)
adds this period 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.LocalDate;
import java.time.Period;
import java.time.temporal.Temporal;
/*from w w w . j ava 2 s. com*/
public class Main {
public static void main(String[] args) {
Period p = Period.ofDays(12);
Temporal l = p.addTo(LocalDate.now());
System.out.println(l);
}
}
The code above generates the following result.