This method subtracts this period from the specified temporal object and returns the same type of temporal object as of the input temporal type.

package com.logicbig.example.period;
import java.time.*;
import java.time.temporal.Temporal;
public class SubtractFromExample {
public static void main(String... args) {
Period p = Period.of(10, 2, 13);
System.out.println(p);
subtract(LocalDate.now(), p);
subtract(LocalDateTime.now(), p);
subtract(OffsetDateTime.now(), p);
subtract(ZonedDateTime.now(), p);
}
private static void subtract(Temporal t, Period p) {
Temporal t2 = p.subtractFrom(t);
String s = t2.getClass().getSimpleName();
System.out.printf("%15s > %s > %s%n", s, t, t2);
}
}
Output
P10Y2M13D
LocalDate > 2025-10-29 > 2015-08-16
LocalDateTime > 2025-10-29T21:25:04.586 > 2015-08-16T21:25:04.586
OffsetDateTime > 2025-10-29T21:25:04.586+08:00 > 2015-08-16T21:25:04.586+08:00
ZonedDateTime > 2025-10-29T21:25:04.587+08:00[America/Chicago] > 2015-08-16T21:25:04.587+08:00[America/Chicago]