/** * Add a amount with the given time unit. For example: * <pre> * new Duration(2, SECONDS).plus(4, MILLISECONDS) * </pre> * will return a Duration of 2004 {@link TimeUnit#MILLISECONDS}. * <p> * <pre> * new Duration(2, SECONDS).plus(1, MINUTES) * </pre> * will return a Duration of 62 {@link TimeUnit#SECONDS}. * * @param amount The amount to add * @param timeUnit The time unit to add * @return A new amount */ public Duration plus(long amount, TimeUnit timeUnit) { if (timeUnit == null) { throw new IllegalArgumentException("Time unit cannot be null"); } return new Plus().apply(this, new Duration(amount, timeUnit)); }
/** * Add a amount with the given time unit. For example: * <pre> * new Duration(2, SECONDS).plus(4, MILLISECONDS) * </pre> * will return a Duration of 2004 {@link TimeUnit#MILLISECONDS}. * <p> * <pre> * new Duration(2, SECONDS).plus(1, MINUTES) * </pre> * will return a Duration of 62 {@link TimeUnit#SECONDS}. * * @param amount The amount to add * @param timeUnit The time unit to add * @return A new amount */ public Duration plus(long amount, TimeUnit timeUnit) { if (timeUnit == null) { throw new IllegalArgumentException("Time unit cannot be null"); } return new Plus().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 plus(Duration duration) { return new Plus().apply(this, duration); }
/** * Add a amount (with the same time unit as the current duration) * * @param amount The amount to add * @return A new amount */ public Duration plus(long amount) { return new Plus().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 plus(Duration duration) { return new Plus().apply(this, duration); }
/** * Add a amount (with the same time unit as the current duration) * * @param amount The amount to add * @return A new amount */ public Duration plus(long amount) { return new Plus().apply(this, unit == null ? FOREVER : new Duration(amount, unit)); }