Class Stopwatch

    • Constructor Detail

      • Stopwatch

        public Stopwatch()
    • Method Detail

      • start

        public void start()
        Starts the Stopwatch.
        Throws:
        IllegalStateException - when Stopwatch is already running.
      • stop

        public void stop()
        Stops the Stopwatch.
        Throws:
        IllegalStateException - when Stopwatch was not yet started or is already stopped.
      • reset

        public void reset()
        Resets the instance to it's initial state.
      • restart

        public void restart()
        Restarts the instance.
      • elapsedMillis

        public long elapsedMillis()
        Get the elapsed time (in ms) between the stopTime and startTime.
        Returns:
        elapsed milliseconds between stopTime and startTime
        Throws:
        IllegalStateException - when Stopwatch has not been started yet
      • elapsedNanos

        public long elapsedNanos()
        Get the elapsed time (in nanoseconds) between the stopTime and startTime.
        Returns:
        elapsed nanoseconds between stopTime and startTime
        Throws:
        IllegalStateException - when Stopwatch has not been started yet
      • isStarted

        public boolean isStarted()
        Get the instance status.
        Returns:
        true if the stopwatch is running, false otherwise