Java Date Time - OffsetTime minus(long amountToSubtract, TemporalUnit unit) example








OffsetTime minus(long amountToSubtract, TemporalUnit unit) returns a copy of this time with the specified amount subtracted.

Syntax

minus has the following syntax.

public OffsetTime minus(long amountToSubtract,  TemporalUnit unit)

Example

The following example shows how to use minus.

import java.time.OffsetTime;
import java.time.temporal.ChronoUnit;
/* ww  w  .  j av a2 s  .com*/
public class Main {
  public static void main(String[] args) {
    OffsetTime m = OffsetTime.now();
    OffsetTime n = m.minus(14,ChronoUnit.DAYS);
    System.out.println(n);

  }
}