Class Time

java.lang.Object
io.github.srcimon.screwbox.core.Time
All Implemented Interfaces:
Serializable

public class Time extends Object implements Serializable
Represents a specific Time after starting the Engine. Can only be used to measure Durations relative to other Time instances. Loses meaning when shutting down the JVM.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Different time units.
  • Method Summary

    Modifier and Type
    Method
    Description
    add(long value, Time.Unit unit)
    Add the given value measured as Time.Unit.
    addMillis(long milliseconds)
    Returns a new instance of Time after the current Time instance.
    addSeconds(long seconds)
    Returns a new instance of Time after the current Time instance.
    static Time
    atNanos(long nanos)
    Returns the a new instance for a specific Time whithin the JVM.
    boolean
     
    int
     
    boolean
    isAfter(Time other)
    Specifies if this instance is after the given Time instance.
    boolean
    isBefore(Time other)
    Specifies if this instance is before the given Time instance.
    boolean
    Returns true if this instance is not unset.
    boolean
    Returns true if this instance is unset.
    long
    The seconds value that represents the current Time.
    long
    The nanoseconds value that represents the current Time.
    static Time
    now()
    Returns a new instance for the current Time.
     
    static Time
    Returns the a new instance of the oldest possible Time.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • unset

      public static Time unset()
      Returns the a new instance of the oldest possible Time.
    • now

      public static Time now()
      Returns a new instance for the current Time.
    • atNanos

      public static Time atNanos(long nanos)
      Returns the a new instance for a specific Time whithin the JVM. Can be handy for testing purposes.
    • nanos

      public long nanos()
      The nanoseconds value that represents the current Time.
    • milliseconds

      public long milliseconds()
      The seconds value that represents the current Time.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • add

      public Time add(long value, Time.Unit unit)
      Add the given value measured as Time.Unit.
    • addSeconds

      public Time addSeconds(long seconds)
      Returns a new instance of Time after the current Time instance.
      See Also:
    • addMillis

      public Time addMillis(long milliseconds)
      Returns a new instance of Time after the current Time instance.
      See Also:
    • isAfter

      public boolean isAfter(Time other)
      Specifies if this instance is after the given Time instance.
    • isBefore

      public boolean isBefore(Time other)
      Specifies if this instance is before the given Time instance.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isUnset

      public boolean isUnset()
      Returns true if this instance is unset.
      See Also:
    • isSet

      public boolean isSet()
      Returns true if this instance is not unset.
      See Also: