Package io.github.srcimon.screwbox.core
Class Time
java.lang.Object
io.github.srcimon.screwbox.core.Time
- All Implemented Interfaces:
Serializable
Represents a specific
Time
after starting the Engine
. Can
only be used to measure Duration
s relative to other Time
instances. Loses meaning when shutting down the JVM.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
Count of nanoseconds per microsecond.static final long
Count of nanoseconds per millisecond.static final long
Count of nanoseconds per second. -
Method Summary
Modifier and TypeMethodDescriptionstatic Time
atNanos
(long nanos) Returns the a new instance for a specificTime
whithin the JVM.boolean
int
hashCode()
boolean
Specifies if this instance is after the givenTime
instance.boolean
Specifies if this instance is before the givenTime
instance.boolean
isSet()
Returnstrue
if this instance is not unset.boolean
isUnset()
Returnstrue
if this instance is unset.long
The seconds value that represents the currentTime
.long
nanos()
The nanoseconds value that represents the currentTime
.static Time
now()
Returns a new instance for the currentTime
.plusMillis
(long milliseconds) plusSeconds
(long seconds) toString()
static Time
unset()
Returns the a new instance of the oldest possibleTime
.
-
Field Details
-
NANOS_PER_SECOND
public static final long NANOS_PER_SECONDCount of nanoseconds per second.- See Also:
-
NANOS_PER_MILLISECOND
public static final long NANOS_PER_MILLISECONDCount of nanoseconds per millisecond.- See Also:
-
NANOS_PER_MICROSECOND
public static final long NANOS_PER_MICROSECONDCount of nanoseconds per microsecond.- See Also:
-
-
Method Details
-
unset
Returns the a new instance of the oldest possibleTime
. -
now
Returns a new instance for the currentTime
. -
atNanos
Returns the a new instance for a specificTime
whithin the JVM. Can be handy for testing purposes. -
nanos
public long nanos()The nanoseconds value that represents the currentTime
. -
milliseconds
public long milliseconds()The seconds value that represents the currentTime
. -
hashCode
public int hashCode() -
equals
-
plusSeconds
- See Also:
-
plusMillis
- See Also:
-
isAfter
Specifies if this instance is after the givenTime
instance. -
isBefore
Specifies if this instance is before the givenTime
instance. -
plus
- See Also:
-
toString
-
isUnset
public boolean isUnset()Returnstrue
if this instance is unset.- See Also:
-
isSet
public boolean isSet()Returnstrue
if this instance is not unset.- See Also:
-