Period subtractFrom(Temporal temporal)
subtracts this period from the specified temporal object.
subtractFrom
has the following syntax.
public Temporal subtractFrom(Temporal temporal)
The following example shows how to use subtractFrom
.
import java.time.LocalDate; import java.time.Period; import java.time.temporal.Temporal; /*from w w w . ja v a2s.com*/ public class Main { public static void main(String[] args) { Period p = Period.ofDays(12); Temporal l = p.subtractFrom(LocalDate.now()); System.out.println(l); } }
The code above generates the following result.