Class Stopwatch


  • public final class Stopwatch
    extends Object
    • Method Detail

      • isRunning

        public boolean isRunning()
        Returns true if start() has been called on this stopwatch, and stop() has not been called since the last call to start().
      • start

        public Stopwatch start()
        Starts the stopwatch.
        Returns:
        this Stopwatch instance
        Throws:
        IllegalStateException - if the stopwatch is already running.
      • stop

        public Stopwatch stop()
        Stops the stopwatch. Future reads will return the fixed duration that had elapsed up to this point.
        Returns:
        this Stopwatch instance
        Throws:
        IllegalStateException - if the stopwatch is already stopped.
      • reset

        public Stopwatch reset()
        Sets the elapsed time for this stopwatch to zero, and places it in a stopped state.
        Returns:
        this Stopwatch instance
      • elapsed

        public Duration elapsed()
        Returns the current elapsed time shown on this stopwatch as a Duration.