Package pl.amazingcode.timeflow
Class Time
- java.lang.Object
-
- pl.amazingcode.timeflow.Time
-
- Direct Known Subclasses:
TestTime
public class Time extends Object
Time is a singleton class that provides access to the current time. It is a wrapper aroundClock. It instantiates an innerClockwithClock.systemUTC(). Time is designed to be used in production code.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedTime()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Clockclock()Returns the clock.static Timeinstance()Returns the singleton instance of Time.Instantnow()Returns the current instant using the clock.protected voidsetClock(Clock clock)
-
-
-
Method Detail
-
instance
public static Time instance()
Returns the singleton instance of Time.- Returns:
- the singleton instance of Time
-
clock
public Clock clock()
Returns the clock. Inner clock is instantiated withClock.systemUTC().- Returns:
- the clock
-
now
public Instant now()
Returns the current instant using the clock.- Returns:
- the current instant
-
setClock
protected void setClock(Clock clock)
-
-