Class GlobalClock


  • public class GlobalClock
    extends java.lang.Object
    This is a centralized global clock. It automaticlaly is inited with the default system clock.
    • Constructor Summary

      Constructors 
      Constructor Description
      GlobalClock()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.time.Clock get()  
      static java.time.Clock install​(java.time.Clock clock)
      You an install and clock based on the java.time.Clock class and make it the central clock.
      static java.time.Clock installFixed​(long epochMillis)
      Install the fixed time clock
      static java.time.Clock installWithOffset​(long offsetinMillis)
      Install a clock that has an offset.
      static long millis()  
      static long offset()  
      static java.time.Clock reset()
      Installs the default system clock again
      • Methods inherited from class java.lang.Object

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

      • GlobalClock

        public GlobalClock()
    • Method Detail

      • get

        public static java.time.Clock get()
      • millis

        public static long millis()
      • offset

        public static long offset()
      • install

        public static java.time.Clock install​(java.time.Clock clock)
        You an install and clock based on the java.time.Clock class and make it the central clock.
        Parameters:
        clock - the clock to use, can be even a static one for testing purposes
        Returns:
        the new clock in case you want to chain
      • installWithOffset

        public static java.time.Clock installWithOffset​(long offsetinMillis)
        Install a clock that has an offset. Make sure we remember the offset.
        Parameters:
        offsetinMillis -
        Returns:
      • installFixed

        public static java.time.Clock installFixed​(long epochMillis)
        Install the fixed time clock
        Parameters:
        epochMillis - the time to return when calling
        Returns:
        the installed clocked
      • reset

        public static java.time.Clock reset()
        Installs the default system clock again
        Returns:
        the installed clock