Package rosequartz.time
Class Moment
java.lang.Object
rosequartz.time.Moment
Represents a moment in time.
-
Constructor Summary
ConstructorsConstructorDescriptionMoment(long unixMillis)
Creates a new moment representing the given unix timestamp. -
Method Summary
Modifier and TypeMethodDescriptionExecutes the given runnable after a given duration.void
Executes the given runnable when the moment happened.static Moment
get()
Creates a moment representing the current time.long
Gets the moment as a unix millisecond-timestamp.boolean
happened()
Gets if the moment already happened.void
ifHappened(Runnable r)
Executes the given runnable if the moment happened.Creates a new moment representing the time in the given duration from this moment.toString()
-
Constructor Details
-
Moment
public Moment(long unixMillis)Creates a new moment representing the given unix timestamp.- Parameters:
unixMillis
- time in unix millis
-
-
Method Details
-
get
Creates a moment representing the current time.- Returns:
- current moment
-
in
Creates a new moment representing the time in the given duration from this moment.- Parameters:
d
- duration from this moment- Returns:
- moment in duration
-
happened
public boolean happened()Gets if the moment already happened. This returns false if the moment is currently happening.- Returns:
- moment happened
-
getTimeMillis
public long getTimeMillis()Gets the moment as a unix millisecond-timestamp.- Returns:
- moment in unix millis
-
ifHappened
Executes the given runnable if the moment happened. -
afterHappened
Executes the given runnable when the moment happened. Note: This method internally uses a Pipeline to check it the moment happened. The runnable will only be executed at the beginning of the next frame when the Moment happened, causing the execution to be delayed by up to 1000ms / {frames per second}. -
after
Executes the given runnable after a given duration. Note: This method internally uses a Pipeline to check it the moment happened. The runnable will only be executed at the beginning of the next frame when the Moment happened, causing the execution to be delayed by up to 1000ms / {frames per second}.- Returns:
- moment that needs to happen for execution
-
toString
-