Class/Object

com.twitter.util

Duration

Related Docs: object Duration | package util

Permalink

sealed class Duration extends TimeLike[Duration] with Serializable

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:

import com.twitter.conversions.time._

3.days+4.nanoseconds

In addition to the timespans in the range of Long.MinValue to Long.MaxValue nanoseconds, durations have two distinguished values: Duration.Top and Duration.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.

Linear Supertypes
Serializable, TimeLike[Duration], Ordered[Duration], Comparable[Duration], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Duration
  2. Serializable
  3. TimeLike
  4. Ordered
  5. Comparable
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. def %(x: Duration): Duration

    Permalink

    Scales this Duration by modding by x.

  4. def *(x: Double): Duration

    Permalink

    Scales this Duration by multiplying by x.

  5. def *(x: Long): Duration

    Permalink

    Scales this Duration by multiplying by x.

  6. def +(delta: Duration): Duration

    Permalink

    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.

    Definition Classes
    TimeLike
  7. def -(delta: Duration): Duration

    Permalink
    Definition Classes
    TimeLike
  8. def /(x: Double): Duration

    Permalink

    Scales this Duration by dividing by x.

  9. def /(x: Long): Duration

    Permalink

    Scales this Duration by dividing by x.

  10. def <(that: Duration): Boolean

    Permalink
    Definition Classes
    Ordered
  11. def <=(that: Duration): Boolean

    Permalink
    Definition Classes
    Ordered
  12. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  13. def >(that: Duration): Boolean

    Permalink
    Definition Classes
    Ordered
  14. def >=(that: Duration): Boolean

    Permalink
    Definition Classes
    Ordered
  15. def abs: Duration

    Permalink

    Converts negative durations to positive durations.

  16. def afterEpoch: Time

    Permalink
  17. def ago: Time

    Permalink
  18. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  19. def ceil(increment: Duration): Duration

    Permalink

    Rounds up to the nearest multiple of the given duration.

    Rounds up to the nearest multiple of the given duration. For example: 127.seconds.ceiling(1.minute) => 3.minutes. Taking the ceiling of a Time object with duration greater than 1.hour can have unexpected results because of timezones.

    Definition Classes
    DurationTimeLike
  20. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. def compare(that: Duration): Int

    Permalink
    Definition Classes
    TimeLike → Ordered
  22. def compareTo(that: Duration): Int

    Permalink
    Definition Classes
    Ordered → Comparable
  23. def diff(that: Duration): Duration

    Permalink

    The difference between the two TimeLikes

    The difference between the two TimeLikes

    Definition Classes
    DurationTimeLike
  24. def div(x: Double): Duration

    Permalink

    See also

    operator /

  25. def div(x: Long): Duration

    Permalink

    See also

    operator /

  26. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  27. def equals(other: Any): Boolean

    Permalink
    Definition Classes
    Duration → AnyRef → Any
  28. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  29. def floor(increment: Duration): Duration

    Permalink

    Rounds down to the nearest multiple of the given duration.

    Rounds down to the nearest multiple of the given duration. For example: 127.seconds.floor(1.minute) => 2.minutes. Taking the floor of a Time object with duration greater than 1.hour can have unexpected results because of timezones.

    Definition Classes
    DurationTimeLike
  30. def fromNow: Time

    Permalink
  31. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  32. def hashCode(): Int

    Permalink
    Definition Classes
    Duration → AnyRef → Any
  33. def inDays: Int

    Permalink
    Definition Classes
    TimeLike
  34. def inHours: Int

    Permalink
    Definition Classes
    TimeLike
  35. def inLongSeconds: Long

    Permalink
    Definition Classes
    TimeLike
  36. def inMicroseconds: Long

    Permalink
    Definition Classes
    TimeLike
  37. def inMillis: Long

    Permalink
    Definition Classes
    TimeLike
  38. def inMilliseconds: Long

    Permalink
    Definition Classes
    TimeLike
  39. def inMinutes: Int

    Permalink
    Definition Classes
    TimeLike
  40. def inNanoseconds: Long

    Permalink

    The TimeLike's value in nanoseconds.

    The TimeLike's value in nanoseconds.

    Definition Classes
    DurationTimeLike
  41. def inSeconds: Int

    Permalink
    Definition Classes
    TimeLike
  42. def inTimeUnit: (Long, TimeUnit)

    Permalink

    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.

    Definition Classes
    TimeLike
  43. def inUnit(unit: TimeUnit): Long

    Permalink

    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.

  44. def isFinite: Boolean

    Permalink

    Is this a finite TimeLike value?

    Is this a finite TimeLike value?

    Definition Classes
    DurationTimeLike
  45. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  46. def isZero: Boolean

    Permalink

    Is this a finite TimeLike value and equals 0

    Is this a finite TimeLike value and equals 0

    Definition Classes
    TimeLike
  47. def max(that: Duration): Duration

    Permalink
    Definition Classes
    TimeLike
  48. def min(that: Duration): Duration

    Permalink
    Definition Classes
    TimeLike
  49. def minus(delta: Duration): Duration

    Permalink

    See also

    operator -

  50. def moreOrLessEquals(other: Duration, maxDelta: Duration): Boolean

    Permalink

    Equality within maxDelta

    Equality within maxDelta

    Definition Classes
    TimeLike
  51. def mul(x: Double): Duration

    Permalink

    See also

    operator *

  52. def mul(x: Long): Duration

    Permalink

    See also

    operator *

  53. val nanos: Long

    Permalink
    Attributes
    protected
  54. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  55. def neg: Duration

    Permalink

    Negates this Duration.

  56. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  57. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  58. val ops: Duration.type

    Permalink
    Attributes
    protected
    Definition Classes
    DurationTimeLike
  59. def plus(delta: Duration): Duration

    Permalink

    See also

    operator +

  60. def rem(x: Duration): Duration

    Permalink

    See also

    operator %

  61. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  62. def toString(): String

    Permalink

    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

    Definition Classes
    Duration → AnyRef → Any
  63. def unary_-: Duration

    Permalink
  64. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  65. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  66. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from TimeLike[Duration]

Inherited from Ordered[Duration]

Inherited from Comparable[Duration]

Inherited from AnyRef

Inherited from Any

Ungrouped