Package org.atlanmod.commons.time
Class Stopwatch
- java.lang.Object
-
- org.atlanmod.commons.time.Stopwatch
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StopwatchcreateStarted()Creates (and starts) a new stopwatch.static StopwatchcreateUnstarted()Creates (but does not start) a new stopwatch.Durationelapsed()Returns the current elapsed time shown on this stopwatch.booleanisRunning()Checks whether this stopwatch is currently running.Stopwatchreset()Sets the elapsed time for this stopwatch to0, and places it in a stopped state.Stopwatchstart()Starts this stopwatch.Stopwatchstop()Stops this stopwatch.
-
-
-
Method Detail
-
createUnstarted
@Nonnull public static Stopwatch createUnstarted()
Creates (but does not start) a new stopwatch.- Returns:
- a new stopwatch
-
createStarted
@Nonnull public static Stopwatch createStarted()
Creates (and starts) a new stopwatch.- Returns:
- a new stopwatch
-
isRunning
public boolean isRunning()
Checks whether this stopwatch is currently running.
-
start
@Nonnull public Stopwatch start()
Starts this stopwatch.- Returns:
- this stopwatch
- Throws:
IllegalStateException- if this stopwatch is already running
-
stop
@Nonnull public Stopwatch stop()
Stops this stopwatch.- Returns:
- this stopwatch
- Throws:
IllegalStateException- if this stopwatch is already stopped
-
reset
@Nonnull public Stopwatch reset()
Sets the elapsed time for this stopwatch to0, and places it in a stopped state.- Returns:
- this stopwatch
-
elapsed
@Nonnull public Duration elapsed()
Returns the current elapsed time shown on this stopwatch. If this stopwatch is currently running, the duration is processed according to the starting point until now.- Returns:
- the duration
-
-