LocalDateTime minus(long amountToSubtract, TemporalUnit unit)
returns a copy of this date-time with the specified amount subtracted.
minus
has the following syntax.
public LocalDateTime minus(long amountToSubtract, TemporalUnit unit)
The following example shows how to use minus
.
import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; /* www . java2 s .co m*/ public class Main { public static void main(String[] args) { LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 00); LocalDateTime t = a.minus(10,ChronoUnit.DAYS); System.out.println(t); } }
The code above generates the following result.