Interface Clock


  • public interface Clock
    Clock interface to allow replacing system clock with a custom one (e.g. for unit testing).
    • Field Detail

      • SYSTEM

        static final Clock SYSTEM
        System clock. Please do not use directly, use system(). This is only visible as we cannot do private modifier in interfaces yet.
    • Method Detail

      • system

        static Clock system()
        Create a clock based on system time.
        Returns:
        clock based on system time
      • nanoTick

        long nanoTick()
        A nanosecond precision tick to use for time measurements. The value is meaningless, it just must increase correctly during a JVM runtime.
        Returns:
        nanosecond value
      • milliTime

        long milliTime()
        A millisecond precision current time, such as provided by System.currentTimeMillis().
        Returns:
        current time in milliseconds