Class Moment

java.lang.Object
rosequartz.time.Moment

public class Moment extends Object
Represents a moment in time.
  • 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

      public static Moment get()
      Creates a moment representing the current time.
      Returns:
      current moment
    • in

      public Moment in(Duration d)
      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

      public void ifHappened(Runnable r)
      Executes the given runnable if the moment happened.
    • afterHappened

      public void afterHappened(Runnable r)
      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

      public Moment after(Duration d, Runnable r)
      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

      public String toString()
      Overrides:
      toString in class Object