Class InstantPatternThreadLocalCachedFormatter
- java.lang.Object
-
- org.apache.logging.log4j.core.util.internal.instant.InstantPatternThreadLocalCachedFormatter
-
- All Implemented Interfaces:
InstantFormatter,InstantPatternFormatter
final class InstantPatternThreadLocalCachedFormatter extends java.lang.Object implements InstantPatternFormatter
AnInstantFormatterwrapper caching the last formatted output in aThreadLocaland trying to reuse it.- Since:
- 2.25.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.util.internal.instant.InstantPatternFormatter
InstantPatternFormatter.Builder
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.ThreadLocal<java.lang.Object[]>epochInstantAndBufferRefprivate java.util.function.Function<Instant,java.lang.Long>epochInstantExtractorprivate InstantPatternFormatterformatterprivate java.time.temporal.ChronoUnitprecision-
Fields inherited from interface org.apache.logging.log4j.core.util.internal.instant.InstantPatternFormatter
LEGACY_FORMATTERS_ENABLED
-
-
Constructor Summary
Constructors Modifier Constructor Description privateInstantPatternThreadLocalCachedFormatter(InstantPatternFormatter formatter, java.util.function.Function<Instant,java.lang.Long> epochInstantExtractor, java.time.temporal.ChronoUnit precision)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.lang.Object[]createEpochInstantAndBuffer()private static java.time.temporal.ChronoUniteffectivePrecision(InstantFormatter formatter, java.time.temporal.ChronoUnit cachePrecision)voidformatTo(java.lang.StringBuilder buffer, Instant instant)java.util.LocalegetLocale()java.lang.StringgetPattern()java.time.temporal.ChronoUnitgetPrecision()java.util.TimeZonegetTimeZone()(package private) static InstantPatternThreadLocalCachedFormatterofMilliPrecision(InstantPatternFormatter formatter)(package private) static InstantPatternThreadLocalCachedFormatterofSecondPrecision(InstantPatternFormatter formatter)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.logging.log4j.core.util.internal.instant.InstantFormatter
format
-
-
-
-
Field Detail
-
formatter
private final InstantPatternFormatter formatter
-
epochInstantExtractor
private final java.util.function.Function<Instant,java.lang.Long> epochInstantExtractor
-
epochInstantAndBufferRef
private final java.lang.ThreadLocal<java.lang.Object[]> epochInstantAndBufferRef
-
precision
private final java.time.temporal.ChronoUnit precision
-
-
Constructor Detail
-
InstantPatternThreadLocalCachedFormatter
private InstantPatternThreadLocalCachedFormatter(InstantPatternFormatter formatter, java.util.function.Function<Instant,java.lang.Long> epochInstantExtractor, java.time.temporal.ChronoUnit precision)
-
-
Method Detail
-
createEpochInstantAndBuffer
private static java.lang.Object[] createEpochInstantAndBuffer()
-
ofMilliPrecision
static InstantPatternThreadLocalCachedFormatter ofMilliPrecision(InstantPatternFormatter formatter)
-
ofSecondPrecision
static InstantPatternThreadLocalCachedFormatter ofSecondPrecision(InstantPatternFormatter formatter)
-
effectivePrecision
private static java.time.temporal.ChronoUnit effectivePrecision(InstantFormatter formatter, java.time.temporal.ChronoUnit cachePrecision)
-
getPrecision
public java.time.temporal.ChronoUnit getPrecision()
- Specified by:
getPrecisionin interfaceInstantFormatter- Returns:
- the time precision of the formatted output
-
formatTo
public void formatTo(java.lang.StringBuilder buffer, Instant instant)- Specified by:
formatToin interfaceInstantFormatter
-
getPattern
public java.lang.String getPattern()
- Specified by:
getPatternin interfaceInstantPatternFormatter
-
getLocale
public java.util.Locale getLocale()
- Specified by:
getLocalein interfaceInstantPatternFormatter
-
getTimeZone
public java.util.TimeZone getTimeZone()
- Specified by:
getTimeZonein interfaceInstantPatternFormatter
-
-