com.twitter.util

Time

object Time extends TimeLikeOps[Time] with Serializable

Use Time.now in your program instead of System.currentTimeMillis, and unit tests will be able to adjust the current time to verify timeouts and other time-dependent behavior, without calling sleep.

If you import the com.twitter.conversions.time implicits you can write human-readable values such as 1.minute or 250.millis.

Linear Supertypes
Serializable, Serializable, TimeLikeOps[Time], AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Time
  2. Serializable
  3. Serializable
  4. TimeLikeOps
  5. AnyRef
  6. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Value Members

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

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

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

    Definition Classes
    AnyRef → Any
  4. val Bottom: Time

    Time Bottom is smaller than any other time, and is equal only to itself.

    Time Bottom is smaller than any other time, and is equal only to itself. It may be used as a sentinel value, representing a time infinitely far in the past.

    Definition Classes
    TimeTimeLikeOps
  5. object Finite

    An extractor for finite TimeLikes; eg.:

    An extractor for finite TimeLikes; eg.:

    duration match {
    case Duration.Finite(d) => ...
    case Duration.Top => ..
    Definition Classes
    TimeLikeOps
  6. object Nanoseconds

    An extractor for finite This, yielding its value in nanoseconds.

    An extractor for finite This, yielding its value in nanoseconds.

    duration match {
    case Duration.Nanoseconds(ns) => ...
    case Duration.Top => ...
    }
    Definition Classes
    TimeLikeOps
  7. val Top: Time

    Time Top is greater than any other definable time, and is equal only to itself.

    Time Top is greater than any other definable time, and is equal only to itself. It may be used as a sentinel value, representing a time infinitely far into the future.

    Definition Classes
    TimeTimeLikeOps
  8. val Undefined: Time

    An undefined value: behaves like Double.NaN

    An undefined value: behaves like Double.NaN

    Definition Classes
    TimeTimeLikeOps
  9. val Zero: Time

    The zero value

    The zero value

    Definition Classes
    TimeLikeOps
  10. def apply(date: Date): Time

  11. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  12. def at(datetime: String): Time

  13. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  14. val epoch: Time

    The unix epoch.

    The unix epoch. Times are measured relative to this.

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

    Definition Classes
    AnyRef
  16. def equals(arg0: Any): Boolean

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

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  18. def fromMicroseconds(micros: Long): Time

    Definition Classes
    TimeLikeOps
  19. def fromMilliseconds(millis: Long): Time

    Definition Classes
    TimeTimeLikeOps
  20. def fromNanoseconds(nanoseconds: Long): Time

    Make a new This from the given number of nanoseconds

    Make a new This from the given number of nanoseconds

    Definition Classes
    TimeTimeLikeOps
  21. def fromRss(rss: String): Time

    Returns the Time parsed from a string in RSS format.

    Returns the Time parsed from a string in RSS format. Eg: "Wed, 15 Jun 2005 19:00:00 GMT"

  22. def fromSeconds(seconds: Int): Time

    Definition Classes
    TimeTimeLikeOps
  23. final def getClass(): Class[_]

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

    Definition Classes
    AnyRef → Any
  25. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  26. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  27. final def notify(): Unit

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

    Definition Classes
    AnyRef
  29. def now: Time

  30. def sleep(duration: Duration): Unit

    Puts the currently executing thread to sleep for the given duration, according to object Time.

    Puts the currently executing thread to sleep for the given duration, according to object Time.

    This is useful for testing.

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

    Definition Classes
    AnyRef
  32. def toString(): String

    Definition Classes
    AnyRef → Any
  33. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  36. def withCurrentTimeFrozen[A](body: (TimeControl) ⇒ A): A

    Runs the given body at the current time.

    Runs the given body at the current time. Makes for simple, fast, predictable unit tests that are dependent on time.

    Note, this intended for use in tests.

    Since this updates shared global state, there are risks about memory visibility with multi-threaded tests.

  37. def withTimeAt[A](time: Time)(body: (TimeControl) ⇒ A): A

    Runs the given body at a specified time.

    Runs the given body at a specified time. Makes for simple, fast, predictable unit tests that are dependent on time.

    Note, this intended for use in tests.

    Since this updates shared global state, there are risks about memory visibility with multi-threaded tests.

  38. def withTimeFunction[A](timeFunction: ⇒ Time)(body: (TimeControl) ⇒ A): A

    Execute body with the time function replaced by timeFunction WARNING: This is only meant for testing purposes.

    Execute body with the time function replaced by timeFunction WARNING: This is only meant for testing purposes. You can break it with nested calls if you have an outstanding Future executing in a worker pool.

Deprecated Value Members

  1. def apply(millis: Long): Time

    Annotations
    @deprecated
    Deprecated

    (Since version 2011-09-12) use Time.fromMilliseconds(...) instead

  2. def measure(f: ⇒ Unit): Duration

    Annotations
    @deprecated
    Deprecated

    (Since version 5.4.0) Use Stopwatch

  3. def measureMany(n: Int)(f: ⇒ Unit): Duration

    Annotations
    @deprecated
    Deprecated

    (Since version 5.4.0) Use Stopwatch

  4. val nanoTimeOffset: Long

    On some systems (os x), nanoTime is just epoch time with greater precision.

    On some systems (os x), nanoTime is just epoch time with greater precision. On others (linux), it can be based on system uptime.

    TODO: This isn't always accurate, an NTP daemon may change at runtime, and so the offset effectively changes.

    Annotations
    @deprecated
    Deprecated

    (Since version 5.4.0) nanoTimeOffset may be dangerous to use

  5. val never: Time

    A time larger than any other finite time.

    A time larger than any other finite time. Synonymous to Top.

    Annotations
    @deprecated
    Deprecated

    (Since version 5.4.0) Use Time.Top

Inherited from Serializable

Inherited from Serializable

Inherited from TimeLikeOps[Time]

Inherited from AnyRef

Inherited from Any

Ungrouped