Class ClockUtil


  • public class ClockUtil
    extends java.lang.Object
    Author:
    Joram Barrez
    • Constructor Summary

      Constructors 
      Constructor Description
      ClockUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Date getCurrentTime()  
      static java.util.Date now()  
      static java.util.Date offset​(java.lang.Long offsetInMillis)
      Moves the clock by the given offset and keeps it running from that point on.
      static void reset()  
      static java.util.Date resetClock()  
      static void setCurrentTime​(java.util.Date currentTime)
      Freezes the clock to a specified Date that will be returned by now() and getCurrentTime()
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ClockUtil

        public ClockUtil()
    • Method Detail

      • setCurrentTime

        public static void setCurrentTime​(java.util.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 java.util.Date getCurrentTime()
      • now

        public static java.util.Date now()
      • offset

        public static java.util.Date offset​(java.lang.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 java.util.Date resetClock()