Class ClockUtil


  • public class ClockUtil
    extends Object
    Author:
    Joram Barrez
    • Constructor Detail

      • ClockUtil

        public ClockUtil()
    • Method Detail

      • setCurrentTime

        public static void setCurrentTime​(Date currentTime)
        Freezes the clock to a specified Date that will be returned by now() and getCurrentTime()
        Parameters:
        currentTime - the Date to freeze the clock at
      • reset

        public static void reset()
      • getCurrentTime

        public static Date getCurrentTime()
      • now

        public static Date now()
      • offset

        public static Date offset​(Long offsetInMillis)
        Moves the clock by the given offset and keeps it running from that point on.
        Parameters:
        offsetInMillis - the offset to move the clock by
        Returns:
        the new 'now'
      • resetClock

        public static Date resetClock()