/** @return A duration that represents the sum of {@code this} and <var>other</var> */ public Duration add(Duration other) { return new Duration(this.ms + other.ms); }
return ( this.ms < 1000 ? this.ms + "ms" : this.ms < 60 * 1000 ? Duration.msToString(this.ms, false) + 's' : this.ms < 24 * 60 * 60 * 1000 ? String.format( Locale.US, (this.ms / (60 * 60 * 1000)), (this.ms / (60 * 1000)) % 60, Duration.msToString(this.ms % (60 * 1000), true) ) : this.ms < 7 * 24 * 60 * 60 * 1000 ? String.format( (this.ms / (60 * 60 * 1000)) % 24, (this.ms / (60 * 1000)) % 60, Duration.msToString(this.ms % (60 * 1000), true) ) : String.format( (this.ms / (60 * 60 * 1000)) % 24, (this.ms / (60 * 1000)) % 60, Duration.msToString(this.ms % (60 * 1000), true)
this.ms = Duration.milliseconds(m.group(1)); return; this.ms = Duration.seconds(m.group(1)) + Duration.sfrac(m.group(2)); return; this.ms = Duration.minutes(m.group(1)); return; this.ms = Duration.minutes(m.group(1)) + Duration.seconds(m.group(2)) + Duration.sfrac(m.group(3)); return; this.ms = Duration.hours(m.group(1)); return; this.ms = Duration.hours(m.group(1)) + Duration.minutes(m.group(2)); return; + Duration.hours(m.group(1)) + Duration.minutes(m.group(2)) + Duration.seconds(m.group(3)) + Duration.sfrac(m.group(4)) ); return; this.ms = Duration.days(m.group(1)); return; + Duration.days(m.group(1))
/** @return The given <var>duration</var> after this {@link PointOfTime} */ public PointOfTime add(Duration duration) { return new PointOfTime(this.ms + duration.milliseconds()); }
); if (!currentDuration.isZero()) { double currentRate = currentQuantity / currentDuration.toSeconds(); Duration cumulatedDuration = previousDuration.add(currentDuration); if (!cumulatedDuration.isZero()) { double cumulatedRate = (previousQuantity + currentQuantity) / cumulatedDuration.toSeconds(); ? (Double) (previousDuration.add(currentDuration).toSeconds() / (previousQuantity + currentQuantity)) : currentQuantity > 0 ? currentDuration.toSeconds() / currentQuantity : null ); if (secondsPerUnit != null) { Duration remainingDuration = new Duration(remainingQuantity * secondsPerUnit);
retryDelay = retryDelay.multiply(Math.pow(this.retryDelayExponent, n)); PointOfTime delayIntervalBegin = this.delayIntervalBegin; if (delayIntervalBegin == null) delayIntervalBegin = new PointOfTime(); Thread.sleep(retryDelay.milliseconds()); } catch (InterruptedException ie) { throw new BuildException(ie);
this.ms = Duration.milliseconds(m.group(1)); return; this.ms = Duration.seconds(m.group(1)) + Duration.sfrac(m.group(2)); return; this.ms = Duration.minutes(m.group(1)); return; this.ms = Duration.minutes(m.group(1)) + Duration.seconds(m.group(2)) + Duration.sfrac(m.group(3)); return; this.ms = Duration.hours(m.group(1)); return; this.ms = Duration.hours(m.group(1)) + Duration.minutes(m.group(2)); return; + Duration.hours(m.group(1)) + Duration.minutes(m.group(2)) + Duration.seconds(m.group(3)) + Duration.sfrac(m.group(4)) ); return; this.ms = Duration.days(m.group(1)); return; + Duration.days(m.group(1))
/** @return The given {@code duration} after this {@link PointOfTime} */ public PointOfTime add(Duration duration) { return new PointOfTime(this.ms + duration.milliseconds()); }
/** @return A duration that is <var>factor</var> as long as this duration */ public Duration multiply(double factor) { return new Duration((long) (this.ms * factor)); }
private void checkConsistency() { PointOfTime beginning = this.beginning; Duration duration = this.duration; PointOfTime ending = this.ending; // Iff all three fields are set, verify that their values are consistent. if (beginning != null && duration != null && ending != null) { if (beginning.milliseconds() + duration.milliseconds() != ending.milliseconds()) { throw new IllegalStateException(); } } } }
return ( this.ms < 1000 ? this.ms + "ms" : this.ms < 60 * 1000 ? Duration.msToString(this.ms, false) + 's' : this.ms < 24 * 60 * 60 * 1000 ? String.format( Locale.US, (this.ms / (60 * 60 * 1000)), (this.ms / (60 * 1000)) % 60, Duration.msToString(this.ms % (60 * 1000), true) ) : this.ms < 7 * 24 * 60 * 60 * 1000 ? String.format( (this.ms / (60 * 60 * 1000)) % 24, (this.ms / (60 * 1000)) % 60, Duration.msToString(this.ms % (60 * 1000), true) ) : String.format( (this.ms / (60 * 60 * 1000)) % 24, (this.ms / (60 * 1000)) % 60, Duration.msToString(this.ms % (60 * 1000), true)
/** @return The length of the interval from <var>other</var> to {@code this} */ public Duration subtract(PointOfTime other) { return new Duration(this.ms - other.ms); }
private void checkConsistency() { PointOfTime beginning = this.beginning; Duration duration = this.duration; PointOfTime ending = this.ending; // Iff all three fields are set, verify that their values are consistent. if (beginning != null && duration != null && ending != null) { if (beginning.milliseconds() + duration.milliseconds() != ending.milliseconds()) { throw new IllegalStateException(); } } } }
/** @return The length of the interval from {@code other} to {@code this} */ public Duration subtract(PointOfTime other) { return new Duration(this.ms - other.ms); }
/** The ending of this time interval */ @Nullable public PointOfTime getEnding() { PointOfTime beginning = this.beginning; Duration duration = this.duration; PointOfTime ending = this.ending; return ( beginning != null && duration != null && ending == null ? new PointOfTime(beginning.milliseconds() + duration.milliseconds()) : this.ending ); }
/** @return A duration which is one {@code divisor}th of this duration long */ public Duration divide(double divisor) { return new Duration((long) (this.ms / divisor)); }
/** The beginning of this time interval */ @Nullable public PointOfTime getBeginning() { PointOfTime beginning = this.beginning; Duration duration = this.duration; PointOfTime ending = this.ending; return ( beginning == null && duration != null && ending != null ? new PointOfTime(ending.milliseconds() - duration.milliseconds()) : this.beginning ); }
/** @return A duration which is one <var>divisor</var>th of this duration long */ public Duration divide(double divisor) { return new Duration((long) (this.ms / divisor)); }
/** The ending of this time interval */ @Nullable public PointOfTime getEnding() { PointOfTime beginning = this.beginning; Duration duration = this.duration; PointOfTime ending = this.ending; return ( beginning != null && duration != null && ending == null ? new PointOfTime(beginning.milliseconds() + duration.milliseconds()) : this.ending ); }
/** @return A duration that represents the sum of {@code this} and {@code other} */ public Duration add(Duration other) { return new Duration(this.ms + other.ms); }