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: AnyRef): Boolean

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

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

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

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

    Definition Classes
    Any
  6. 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
  7. object Finite

    An extractor for finite TimeLikes; eg.

  8. object Nanoseconds

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

  9. 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
  10. val Undefined: Time

    An undefined value: behaves like Double.

    An undefined value: behaves like Double.NaN

    Definition Classes
    TimeTimeLikeOps
  11. val Zero: Time

    The zero value

    The zero value

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

  13. final def asInstanceOf[T0]: T0

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

  15. def clone(): AnyRef

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

    The unix epoch.

    The unix epoch. Times are measured relative to this.

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

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

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

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  20. def fromMilliseconds(millis: Long): Time

    Definition Classes
    TimeTimeLikeOps
  21. 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
  22. 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"

  23. def fromSeconds(seconds: Int): Time

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

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

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

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

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

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

    Definition Classes
    AnyRef
  30. def now: Time

  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 functionality isn't thread safe, as Time.

    Execute body with the time function replaced by timeFunction WARNING: This functionality isn't thread safe, as Time.fn is a global! It must be used only for testing purpose.

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