Class TestTimeService
java.lang.Object
com.reallifedeveloper.common.domain.TestTimeService
- All Implemented Interfaces:
TimeService
An implementation of the
TimeService interface useful for testing.
The now() method returns a predefined set of dates.
- Author:
- RealLifeDeveloper
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe format used when parsing date and time strings ("yyyy-MM-dd HH:mm:ssX"). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGives the list of dates that are returned by this service.now()voidsetDateTimes(String... dateTimeStrings) Sets the DateTimes returned from thenow()method.voidsetDateTimes(ZonedDateTime... dateTimes) Sets the DateTimes returned from thenow()method.
-
Field Details
-
DATE_TIME_FORMAT
The format used when parsing date and time strings ("yyyy-MM-dd HH:mm:ssX").- See Also:
-
-
Constructor Details
-
TestTimeService
public TestTimeService()
-
-
Method Details
-
now
This method returns the DateTimes set using the
setDateTimes(String...)method. If it is called more times than there are test dates defined, it starts over again from the first test date.- Specified by:
nowin interfaceTimeService
-
dateTimes
Gives the list of dates that are returned by this service.- Returns:
- the list of dates returned by this service
-
setDateTimes
Sets the DateTimes returned from thenow()method.- Parameters:
dateTimes- the dates thenow()method should return
-
setDateTimes
Sets the DateTimes returned from thenow()method.- Parameters:
dateTimeStrings- the dates thenow()method should return, on the format "yyyy-MM-dd HH:mm:ssX"
-