Package io.github.srcimon.screwbox.core
Class Duration
java.lang.Object
io.github.srcimon.screwbox.core.Duration
- All Implemented Interfaces:
Serializable
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic Duration
Creates a new instance with the duration between two givenTime
values.boolean
int
hashCode()
boolean
boolean
isLessThan
(Duration other) boolean
isNone()
Checks if duration has no length.long
Returns the total milliseconds of theDuration
.long
nanos()
Returns the total nanoseconds of theDuration
.static Duration
none()
Creates a new instance with no duration at all.static Duration
ofExecution
(Runnable execution) Creates a new instance with the duration of the time it took to execute the givenRunnable
.static Duration
ofMicros
(long micros) Creates a new instance with the duration of the given value of microseconds.static Duration
ofMillis
(long millis) Creates a new instance with the duration of the given value of milliseconds.static Duration
ofNanos
(long nanos) Creates a new instance with the duration of the given value of nanoseconds.static Duration
ofSeconds
(long seconds) Creates a new instance with the duration of the given value of seconds.long
seconds()
Returns the total seconds of theDuration
.static Duration
Creates a new instance with the duration since the givenTime
value.toString()
-
Method Details
-
ofNanos
Creates a new instance with the duration of the given value of nanoseconds.- See Also:
-
ofMicros
Creates a new instance with the duration of the given value of microseconds.- See Also:
-
ofMillis
Creates a new instance with the duration of the given value of milliseconds.- See Also:
-
ofSeconds
Creates a new instance with the duration of the given value of seconds.- See Also:
-
since
Creates a new instance with the duration since the givenTime
value.- See Also:
-
none
Creates a new instance with no duration at all.- See Also:
-
isNone
public boolean isNone()Checks if duration has no length. -
ofExecution
Creates a new instance with the duration of the time it took to execute the givenRunnable
.- Parameters:
execution
- the execution that is measured
-
between
Creates a new instance with the duration between two givenTime
values. -
milliseconds
public long milliseconds()Returns the total milliseconds of theDuration
.- See Also:
-
nanos
public long nanos()Returns the total nanoseconds of theDuration
.- See Also:
-
seconds
public long seconds()Returns the total seconds of theDuration
.- See Also:
-
add
-
toString
-
hashCode
public int hashCode() -
equals
-
isAtLeast
-
isLessThan
-
addTo
-
humanReadable
-