Class FixedPreciseClock

java.lang.Object
org.apache.logging.log4j.core.time.internal.FixedPreciseClock
All Implemented Interfaces:
PreciseClock, Clock

public class FixedPreciseClock extends Object implements PreciseClock
Implementation of the PreciseClock interface that always returns a fixed time value.
Since:
2.11
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final long
     
    private final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a FixedPreciseClock that always returns the epoch.
    FixedPreciseClock(long currentTimeMillis)
    Constructs a FixedPreciseClock that always returns the specified time in milliseconds since the epoch.
    FixedPreciseClock(long currentTimeMillis, int nanosOfMillisecond)
    Constructs a FixedPreciseClock that always returns the specified time in milliseconds since the epoch and nanosecond of the millisecond.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the time in milliseconds since the epoch.
    void
    Initializes the specified instant with time information as accurate as available on this platform.

    Methods inherited from class java.lang.Object

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

    • currentTimeMillis

      private final long currentTimeMillis
    • nanosOfMillisecond

      private final int nanosOfMillisecond
  • Constructor Details

    • FixedPreciseClock

      public FixedPreciseClock()
      Constructs a FixedPreciseClock that always returns the epoch.
    • FixedPreciseClock

      public FixedPreciseClock(long currentTimeMillis)
      Constructs a FixedPreciseClock that always returns the specified time in milliseconds since the epoch.
      Parameters:
      currentTimeMillis - milliseconds since the epoch
    • FixedPreciseClock

      public FixedPreciseClock(long currentTimeMillis, int nanosOfMillisecond)
      Constructs a FixedPreciseClock that always returns the specified time in milliseconds since the epoch and nanosecond of the millisecond.
      Parameters:
      currentTimeMillis - milliseconds since the epoch
      nanosOfMillisecond - nanosecond of the specified millisecond
  • Method Details

    • init

      public void init(MutableInstant instant)
      Description copied from interface: PreciseClock
      Initializes the specified instant with time information as accurate as available on this platform.
      Specified by:
      init in interface PreciseClock
      Parameters:
      instant - the container to be initialized with the accurate time information
    • currentTimeMillis

      public long currentTimeMillis()
      Description copied from interface: Clock
      Returns the time in milliseconds since the epoch.
      Specified by:
      currentTimeMillis in interface Clock
      Returns:
      the time in milliseconds since the epoch