Class ApplicationClock

java.lang.Object
de.galan.commons.time.ApplicationClock

public class ApplicationClock extends Object
Clock that acts as time emitter for the application. Uses a java.time.clock.SystemClock (UTC) by default.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Clock
    Returns the configured application Clock instance.
    static void
    Resets the application clock to the default.
    static void
    setClock(Clock clock)
    Sets the application clock.
    static void
    Creates a fixed Clock.
    static void
    Creates a fixed Clock with the input format "yyyy-MM-dd HH:mm:ss" using the local (systemDefault) timezone.
    static void
    setUtc(String time)
    Creates a fixed Clock with the input format "yyyy-MM-dd'T'HH:mm:ss'Z'" using UTC as timezone.
    static void
    setUtc(Date time)
    Creates a fixed Clock.

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • ApplicationClock

      public ApplicationClock()
  • Method Details

    • getClock

      public static Clock getClock()
      Returns the configured application Clock instance.
    • setClock

      public static void setClock(Clock clock)
      Sets the application clock. This should be done only at startup (usually not necessary), or in unit tests.
    • reset

      public static void reset()
      Resets the application clock to the default.
    • setIso

      public static void setIso(Instant time)
      Creates a fixed Clock.
    • setUtc

      public static void setUtc(Date time)
      Creates a fixed Clock.
    • setUtc

      public static void setUtc(String time)
      Creates a fixed Clock with the input format "yyyy-MM-dd'T'HH:mm:ss'Z'" using UTC as timezone.
    • setLocal

      public static void setLocal(String time)
      Creates a fixed Clock with the input format "yyyy-MM-dd HH:mm:ss" using the local (systemDefault) timezone.