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.
An extractor for finite TimeLikes; eg.
An extractor for finite This
, yielding its value in nanoseconds.
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.
An undefined value: behaves like Double.
An undefined value: behaves like Double.NaN
The zero value
The zero value
The unix epoch.
The unix epoch. Times are measured relative to this.
Make a new This
from the given number of nanoseconds
Make a new This
from the given number of nanoseconds
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"
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.
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.
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.
(Since version 2011-09-12) use Time.fromMilliseconds(...) instead
(Since version 5.4.0) Use Stopwatch
(Since version 5.4.0) Use Stopwatch
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.
(Since version 5.4.0) nanoTimeOffset may be dangerous to use
A time larger than any other finite time.
A time larger than any other finite time. Synonymous to Top
.
(Since version 5.4.0) Use Time.Top
Use
Time.now
in your program instead ofSystem.currentTimeMillis
, and unit tests will be able to adjust the current time to verify timeouts and other time-dependent behavior, without callingsleep
.If you import the com.twitter.conversions.time implicits you can write human-readable values such as
1.minute
or250.millis
.