Class FixedPreciseClock
- java.lang.Object
-
- org.apache.logging.log4j.core.time.internal.FixedPreciseClock
-
- All Implemented Interfaces:
PreciseClock,Clock
public class FixedPreciseClock extends java.lang.Object implements PreciseClock
Implementation of thePreciseClockinterface that always returns a fixed time value.- Since:
- 2.11
-
-
Field Summary
Fields Modifier and Type Field Description private longcurrentTimeMillisprivate intnanosOfMillisecond
-
Constructor Summary
Constructors Constructor Description FixedPreciseClock()Constructs aFixedPreciseClockthat always returns the epoch.FixedPreciseClock(long currentTimeMillis)Constructs aFixedPreciseClockthat always returns the specified time in milliseconds since the epoch.FixedPreciseClock(long currentTimeMillis, int nanosOfMillisecond)Constructs aFixedPreciseClockthat always returns the specified time in milliseconds since the epoch and nanosecond of the millisecond.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longcurrentTimeMillis()Returns the time in milliseconds since the epoch.voidinit(MutableInstant instant)Initializes the specified instant with time information as accurate as available on this platform.
-
-
-
Constructor Detail
-
FixedPreciseClock
public FixedPreciseClock()
Constructs aFixedPreciseClockthat always returns the epoch.
-
FixedPreciseClock
public FixedPreciseClock(long currentTimeMillis)
Constructs aFixedPreciseClockthat always returns the specified time in milliseconds since the epoch.- Parameters:
currentTimeMillis- milliseconds since the epoch
-
FixedPreciseClock
public FixedPreciseClock(long currentTimeMillis, int nanosOfMillisecond)Constructs aFixedPreciseClockthat always returns the specified time in milliseconds since the epoch and nanosecond of the millisecond.- Parameters:
currentTimeMillis- milliseconds since the epochnanosOfMillisecond- nanosecond of the specified millisecond
-
-
Method Detail
-
init
public void init(MutableInstant instant)
Description copied from interface:PreciseClockInitializes the specified instant with time information as accurate as available on this platform.- Specified by:
initin interfacePreciseClock- Parameters:
instant- the container to be initialized with the accurate time information
-
currentTimeMillis
public long currentTimeMillis()
Description copied from interface:ClockReturns the time in milliseconds since the epoch.- Specified by:
currentTimeMillisin interfaceClock- Returns:
- the time in milliseconds since the epoch
-
-