Class Ticks

java.lang.Object
com.ultikits.ultitools.scheduling.Ticks

public final class Ticks extends Object
Tick/duration conversions at the nominal 20 ticks per second.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final long
     
    static final Duration
    One tick, 50 ms.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static long
    ceil(Duration duration)
    Returns whole ticks covering the duration, rounded up: zero to 0, 1 ms to 1, 50 ms to 1, and 51 ms to 2.
    static Duration
    of(long ticks)
    Returns ticks * 50 ms without overflowing an intermediate millisecond count.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • TICK

      public static final Duration TICK
      One tick, 50 ms.
    • NANOS_PER_TICK

      private static final long NANOS_PER_TICK
      See Also:
  • Constructor Details

    • Ticks

      private Ticks()
  • Method Details

    • of

      public static Duration of(long ticks)
      Returns ticks * 50 ms without overflowing an intermediate millisecond count.
      Throws:
      IllegalArgumentException - if ticks is negative
    • ceil

      public static long ceil(Duration duration)
      Returns whole ticks covering the duration, rounded up: zero to 0, 1 ms to 1, 50 ms to 1, and 51 ms to 2.
      Throws:
      IllegalArgumentException - if the duration is negative
      ArithmeticException - if the tick count overflows a long