com.twitter.util

Duration

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
Learn more about member selection
Visibility
  1. Public
  2. All

Value Members

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

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

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

    Scales this Duration by modding by x.

  5. def *(x: Double): Duration

    Scales this Duration by multiplying by x.

  6. def *(x: Long): Duration

    Scales this Duration by multiplying by x.

  7. def +(delta: Duration): Duration

    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
  8. def -(delta: Duration): Duration

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

    Scales this Duration by dividing by x.

  10. def /(x: Long): Duration

    Scales this Duration by dividing by x.

  11. def <(that: Duration): Boolean

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

    Definition Classes
    Ordered
  13. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  14. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  15. def >(that: Duration): Boolean

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

    Definition Classes
    Ordered
  17. def abs: Duration

    Converts negative durations to positive durations.

  18. def afterEpoch: Time

  19. def ago: Time

  20. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  21. def ceil(increment: Duration): Duration

    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
  22. def clone(): AnyRef

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

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

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

    The difference between the two TimeLikes

    The difference between the two TimeLikes

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

    See also

    operator /

  27. def div(x: Long): Duration

    See also

    operator /

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

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

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

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

    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
  32. def fromNow: Time

  33. final def getClass(): Class[_]

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

    Definition Classes
    Duration → AnyRef → Any
  35. def inDays: Int

    Definition Classes
    TimeLike
  36. def inHours: Int

    Definition Classes
    TimeLike
  37. def inLongSeconds: Long

    Definition Classes
    TimeLike
  38. def inMicroseconds: Long

    Definition Classes
    TimeLike
  39. def inMillis: Long

    Definition Classes
    TimeLike
  40. def inMilliseconds: Long

    Definition Classes
    TimeLike
  41. def inMinutes: Int

    Definition Classes
    TimeLike
  42. def inNanoseconds: Long

    The TimeLike's value in nanoseconds.

    The TimeLike's value in nanoseconds.

    Definition Classes
    DurationTimeLike
  43. def inSeconds: Int

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

    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
  45. def inUnit(unit: TimeUnit): Long

    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.

  46. def isFinite: Boolean

    Is this a finite TimeLike value?

    Is this a finite TimeLike value?

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

    Definition Classes
    Any
  48. def max(that: Duration): Duration

    Definition Classes
    TimeLike
  49. def min(that: Duration): Duration

    Definition Classes
    TimeLike
  50. def minus(delta: Duration): Duration

    See also

    operator -

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

    Equality within maxDelta

    Equality within maxDelta

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

    See also

    operator *

  53. def mul(x: Long): Duration

    See also

    operator *

  54. val nanos: Long

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

    Definition Classes
    AnyRef
  56. def neg: Duration

    Negates this Duration.

  57. final def notify(): Unit

    Definition Classes
    AnyRef
  58. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  59. val ops: Duration.type

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

    See also

    operator +

  61. def rem(x: Duration): Duration

    See also

    operator %

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

    Definition Classes
    AnyRef
  63. def toString(): String

    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
  64. def unary_-: Duration

  65. final def wait(): Unit

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

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

    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