OffsetDateTime minus(long amountToSubtract, TemporalUnit unit)
returns a copy of this date-time with the specified amount subtracted.
minus
has the following syntax.
public OffsetDateTime minus(long amountToSubtract, TemporalUnit unit)
The following example shows how to use minus
.
import java.time.OffsetDateTime; import java.time.temporal.ChronoUnit; /*from w w w . j a v a2s . 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.