Scales this Duration
by modding by x
.
Scales this Duration
by multiplying by x
.
Scales this Duration
by multiplying by x
.
Adds delta
to this TimeLike
.
Adds delta
to this TimeLike
. Adding Duration.Top
results
in the TimeLike
's Top
, adding Duration.Bottom
results in
the TimeLike
's Bottom
.
Scales this Duration
by dividing by x
.
Scales this Duration
by dividing by x
.
Converts negative durations to positive durations.
Rounds up to the nearest multiple of the given duration.
The difference between the two TimeLike
s
operator /
operator /
Rounds down to the nearest multiple of the given duration.
The TimeLike
's value in nanoseconds.
Returns a value/TimeUnit
pair; attempting to return coarser
grained values if possible (specifically: TimeUnit.SECONDS
or
TimeUnit.MILLISECONDS
) before resorting to the default
TimeUnit.NANOSECONDS
.
Returns a value/TimeUnit
pair; attempting to return coarser
grained values if possible (specifically: TimeUnit.SECONDS
or
TimeUnit.MILLISECONDS
) before resorting to the default
TimeUnit.NANOSECONDS
.
Returns the length of the duration in the given TimeUnit.
Returns the length of the duration in the given TimeUnit.
In general, a simpler approach is to use the named methods (eg. inSeconds) However, this is useful for more programmatic call sites.
Is this a finite TimeLike value?
Is this a finite TimeLike value and equals 0
Is this a finite TimeLike value and equals 0
operator -
Equality within maxDelta
Equality within maxDelta
operator *
operator *
Negates this Duration
.
operator +
operator %
toString produces a representation that
toString produces a representation that
- loses no information - is easy to read - can be read back in if com.twitter.conversions.time._ is imported
An example:
com.twitter.util.Duration(9999999, java.util.concurrent.TimeUnit.MICROSECONDS) res0: com.twitter.util.Duration = 9.seconds+999.milliseconds+999.microseconds
A
Duration
represents the span between two points in time. It represents this with a signed long, and thus the largest representable duration is:106751.days+23.hours+47.minutes+16.seconds +854.milliseconds+775.microseconds+807.nanoseconds
Durations may be constructed via its companion object,
Duration.fromNanoseconds
,Duration.fromSeconds
, etc. or by using the time conversions:In addition to the timespans in the range of
Long.MinValue
toLong.MaxValue
nanoseconds, durations have two distinguished values:Duration.Top
andDuration.Bottom
. These have special semantics:Top
is greater than every other duration, save for itself;Bottom
is smaller than any duration except for itself — they act like positive and negative infinity, and their arithmetic follows. This is useful for representing durations that are truly infinite; for example the absence of a timeout.