Class ClockTimeService
java.lang.Object
com.reallifedeveloper.common.domain.ClockTimeService
- All Implemented Interfaces:
TimeService
An implementation of the
TimeService
interface that uses a java.time.Clock
. The clock is by default
Clock.systemUTC()
but can be changed using the setClock(clock)
method.- Author:
- RealLifeDeveloper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionnow()
Gives the current time as ajava.time.ZonedDateTime
object.void
Sets thejava.time.Clock
used by thisClockTimeService
.
-
Constructor Details
-
ClockTimeService
public ClockTimeService()
-
-
Method Details
-
now
Description copied from interface:TimeService
Gives the current time as ajava.time.ZonedDateTime
object.- Specified by:
now
in interfaceTimeService
- Returns:
- the current time
-
setClock
Sets thejava.time.Clock
used by thisClockTimeService
.- Parameters:
clock
- the newClock
to use
-