Class ClockTimeService

java.lang.Object
com.reallifedeveloper.common.domain.ClockTimeService
All Implemented Interfaces:
TimeService

public class ClockTimeService extends Object implements 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 Details

    • ClockTimeService

      public ClockTimeService()
  • Method Details

    • now

      public ZonedDateTime now()
      Description copied from interface: TimeService
      Gives the current time as a java.time.ZonedDateTime object.
      Specified by:
      now in interface TimeService
      Returns:
      the current time
    • setClock

      public void setClock(Clock clock)
      Sets the java.time.Clock used by this ClockTimeService.
      Parameters:
      clock - the new Clock to use