A clock providing access to the current instant, date and time using a time-zone.
Instances of this class are used to find the current instant, which can be
interpreted using the stored time-zone to find the current date and time.
As such, a clock can be used instead of
The primary purpose of this abstraction is to allow alternate clocks to be plugged in as and when required. Applications use an object to obtain the current time rather than a static method. This can simplify testing.
Applications should avoid using the top level objects directly.
Instead, they should pass a
Clock into any method that requires it.
A dependency injection framework is one way to achieve this.
This approach allows an alternate clock, such as
fixedTime() to be used during testing.
systemTime top level factory method offers clocks based on the best available
system clock, such as
no type hierarchy
no supertypes hierarchy