Class 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 around Clock. It instantiates an inner Clock with Clock.systemUTC(). Time is designed to be used in production code.
    • Constructor Detail

      • Time

        protected Time()
    • 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 with Clock.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)