Class TestTimer

  • All Implemented Interfaces:
    Timer

    public class TestTimer
    extends java.lang.Object
    implements Timer
    A Timer to be used in tests when the advancement of time needs to be controlled.
    Author:
    hakonhall
    • Constructor Detail

      • TestTimer

        public TestTimer()
    • Method Detail

      • setMillis

        public void setMillis​(long millisSinceEpoch)
      • advanceMillis

        public void advanceMillis​(long millis)
      • advanceSeconds

        public void advanceSeconds​(long seconds)
      • advanceMinutes

        public void advanceMinutes​(long minutes)
      • advance

        public void advance​(java.time.Duration duration)
      • currentTimeMillis

        public long currentTimeMillis()
        Description copied from interface: Timer

        Returns the current time in milliseconds. Note that while the unit of time of the return value is a millisecond, the granularity of the value depends on the underlying operating system and may be larger. For example, many operating systems measure time in units of tens of milliseconds.

        See the description of the class Date for a discussion of slight discrepancies that may arise between "computer time" and coordinated universal time (UTC).

        Specified by:
        currentTimeMillis in interface Timer
        Returns:
        The difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.
        See Also:
        Date