OffsetDateTime minus(TemporalAmount amountToSubtract) example
Description
OffsetDateTime minus(TemporalAmount amountToSubtract)
returns a copy of this date-time with the specified amount subtracted.
Syntax
minus
has the following syntax.
public OffsetDateTime minus(TemporalAmount amountToSubtract)
Example
The following example shows how to use minus
.
import java.time.OffsetDateTime;
import java.time.temporal.ChronoUnit;
/*from w w w .j av a2 s . c om*/
public class Main {
public static void main(String[] args) {
OffsetDateTime o = OffsetDateTime.now();
OffsetDateTime d = o.minus(20,ChronoUnit.HOURS);
System.out.println(d);
}
}
The code above generates the following result.