Package de.galan.commons.time
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 StringDATE_FORMAT
-
Constructor Summary
Constructors Constructor Description ApplicationClock()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ClockgetClock()Returns the configured application Clock instance.static voidreset()Resets the application clock to the default.static voidsetClock(Clock clock)Sets the application clock.static voidsetIso(Instant time)Creates a fixed Clock.static voidsetLocal(String time)Creates a fixed Clock with the input format "yyyy-MM-dd HH:mm:ss" using the local (systemDefault) timezone.static voidsetUtc(String time)Creates a fixed Clock with the input format "yyyy-MM-dd'T'HH:mm:ss'Z'" using UTC as timezone.static voidsetUtc(Date time)Creates a fixed Clock.
-
-
-
Field Detail
-
DATE_FORMAT
public static final String DATE_FORMAT
- See Also:
- Constant Field Values
-
-
Method Detail
-
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.
-
-