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:
  • Field Details

    • NANOS_PER_SECOND

      public static final long NANOS_PER_SECOND
      Count of nanoseconds per second.
      See Also:
    • NANOS_PER_MILLISECOND

      public static final long NANOS_PER_MILLISECOND
      Count of nanoseconds per millisecond.
      See Also:
    • NANOS_PER_MICROSECOND

      public static final long NANOS_PER_MICROSECOND
      Count of nanoseconds per microsecond.
      See Also:
  • 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
    • plusSeconds

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

      public Time plusMillis(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.
    • plus

      public Time plus(Duration duration)
      Returns a new instance of Time after the current Time instance.
      See Also:
    • 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: