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.ZonedDateTimeobject.voidSets thejava.time.Clockused by thisClockTimeService.
-
Constructor Details
-
ClockTimeService
public ClockTimeService()
-
-
Method Details
-
now
Description copied from interface:TimeServiceGives the current time as ajava.time.ZonedDateTimeobject.- Specified by:
nowin interfaceTimeService- Returns:
- the current time
-
setClock
Sets thejava.time.Clockused by thisClockTimeService.- Parameters:
clock- the newClockto use
-