getTime

fun getTime(unit: DurationUnit = DurationUnit.SECONDS, decimals: Int = 2): String

Duration value expressed in the given unit and formatted with the specified decimals-amount of digits after the decimal point.

The stopwatch must be started and stopped before calling this method or toString. If any of the aforementioned methods are called, but the stopwatch was not started and stopped yet first, an IllegalStateException will be thrown.

Return

The elapsed time, formatted with the provided formatting.

Author

Griefed

Parameters

unit

Unit to use in duration representation.

decimals

The number of digits after decimal point to show. The value must be non-negative. No more than 12 decimals will be shown, even if a larger number is requested.

Throws

if the watch was not started.