Enum InstantNumberFormatter

java.lang.Object
java.lang.Enum<InstantNumberFormatter>
org.apache.logging.log4j.core.util.internal.instant.InstantNumberFormatter
All Implemented Interfaces:
Serializable, Comparable<InstantNumberFormatter>, InstantFormatter

public enum InstantNumberFormatter extends Enum<InstantNumberFormatter> implements InstantFormatter
Formats an Instant numerically; e.g., formats its epoch1 seconds.

1 Epoch is a fixed instant on 1970-01-01Z.

Internal usage only!

This class is intended only for internal Log4j usage. Log4j users should not use this class! This class is not subject to any backward compatibility concerns.

Since:
2.25.0
  • Enum Constant Details

    • EPOCH_NANOS

      public static final InstantNumberFormatter EPOCH_NANOS
      Formats nanoseconds since epoch; e.g., 1581082727982123456.
    • EPOCH_MILLIS

      public static final InstantNumberFormatter EPOCH_MILLIS
      Formats milliseconds since epoch, including the nanosecond fraction; e.g., 1581082727982.123456. The nanosecond fraction will be skipped if it is zero.
    • EPOCH_MILLIS_ROUNDED

      public static final InstantNumberFormatter EPOCH_MILLIS_ROUNDED
      Formats milliseconds since epoch, excluding the nanosecond fraction; e.g., 1581082727982.
    • EPOCH_MILLIS_NANOS

      public static final InstantNumberFormatter EPOCH_MILLIS_NANOS
      Formats the nanosecond fraction of milliseconds since epoch; e.g., 123456.
    • EPOCH_SECONDS

      public static final InstantNumberFormatter EPOCH_SECONDS
      Formats seconds since epoch, including the nanosecond fraction; e.g., 1581082727.982123456. The nanosecond fraction will be skipped if it is zero.
    • EPOCH_SECONDS_ROUNDED

      public static final InstantNumberFormatter EPOCH_SECONDS_ROUNDED
      Formats seconds since epoch, excluding the nanosecond fraction; e.g., 1581082727. The nanosecond fraction will be skipped if it is zero.
    • EPOCH_SECONDS_NANOS

      public static final InstantNumberFormatter EPOCH_SECONDS_NANOS
      Formats the nanosecond fraction of seconds since epoch; e.g., 982123456.
  • Method Details

    • values

      public static InstantNumberFormatter[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static InstantNumberFormatter valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • getPrecision

      public ChronoUnit getPrecision()
      Specified by:
      getPrecision in interface InstantFormatter
      Returns:
      the time precision of the formatted output
    • formatTo

      public void formatTo(StringBuilder buffer, Instant instant)
      Specified by:
      formatTo in interface InstantFormatter