Package cn.sliew.milky.common.stopwatch
Class Stopwatch
- java.lang.Object
-
- cn.sliew.milky.common.stopwatch.Stopwatch
-
public final class Stopwatch extends Object
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Durationelapsed()Returns the current elapsed time shown on this stopwatch as aDuration.booleanisRunning()Stopwatchreset()Sets the elapsed time for this stopwatch to zero, and places it in a stopped state.Stopwatchstart()Starts the stopwatch.Stopwatchstop()Stops the stopwatch.
-
-
-
Method Detail
-
isRunning
public boolean isRunning()
-
start
public Stopwatch start()
Starts the stopwatch.- Returns:
- this
Stopwatchinstance - 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
Stopwatchinstance - 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
Stopwatchinstance
-
-