/** * Subtract an amount with the given time unit. For example: * <pre> * new Duration(2, SECONDS).minus(4, MILLISECONDS) * </pre> * will return a Duration of 1996 {@link TimeUnit#MILLISECONDS}. * <p> * <pre> * new Duration(2, MINUTES).minus(1, SECONDS) * </pre> * will return a Duration of 119 {@link TimeUnit#SECONDS}. * * @param amount The amount to add * @param timeUnit The time unit to add * @return A new amount */ public Duration minus(long amount, TimeUnit timeUnit) { if (timeUnit == null) { throw new IllegalArgumentException("Time unit cannot be null"); } return new Minus().apply(this, new Duration(amount, timeUnit)); }
/** * Subtract an amount with the given time unit. For example: * <pre> * new Duration(2, SECONDS).minus(4, MILLISECONDS) * </pre> * will return a Duration of 1996 {@link TimeUnit#MILLISECONDS}. * <p> * <pre> * new Duration(2, MINUTES).minus(1, SECONDS) * </pre> * will return a Duration of 119 {@link TimeUnit#SECONDS}. * * @param amount The amount to add * @param timeUnit The time unit to add * @return A new amount */ public Duration minus(long amount, TimeUnit timeUnit) { if (timeUnit == null) { throw new IllegalArgumentException("Time unit cannot be null"); } return new Minus().apply(this, new Duration(amount, timeUnit)); }
/** * Add a duration with the given time unit. For example: * <pre> * new Duration(2, SECONDS).plus(Duration.FIVE_HUNDRED_MILLISECONDS) * </pre> * will return a Duration of 2500 {@link TimeUnit#MILLISECONDS}. * <p> * * @param duration The duration to add * @return A new duration */ public Duration minus(Duration duration) { return new Minus().apply(this, duration); }
/** * Subtract an amount (with the same time unit as the current amount) * * @param amount The amount to add * @return A new amount */ public Duration minus(long amount) { return new Minus().apply(this, unit == null ? FOREVER : new Duration(amount, unit)); }
/** * Add a duration with the given time unit. For example: * <pre> * new Duration(2, SECONDS).plus(Duration.FIVE_HUNDRED_MILLISECONDS) * </pre> * will return a Duration of 2500 {@link TimeUnit#MILLISECONDS}. * <p> * * @param duration The duration to add * @return A new duration */ public Duration minus(Duration duration) { return new Minus().apply(this, duration); }
/** * Subtract an amount (with the same time unit as the current amount) * * @param amount The amount to add * @return A new amount */ public Duration minus(long amount) { return new Minus().apply(this, unit == null ? FOREVER : new Duration(amount, unit)); }