Class InstantFormatter
- java.lang.Object
-
- org.apache.logging.log4j.layout.template.json.util.InstantFormatter
-
public final class InstantFormatter extends java.lang.ObjectA compositeInstantformatter trying to employ eitherFixedDateFormat,FastDateFormat, orDateTimeFormatterin the given order due to performance reasons.Note that
FixedDateFormatandFastDateFormatonly support millisecond precision. If the pattern asks for a higher precision,DateTimeFormatterwill be employed, which is significantly slower.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classInstantFormatter.Builderprivate static interfaceInstantFormatter.Formatterprivate static interfaceInstantFormatter.FormatterFactoryprivate static classInstantFormatter.JavaDateTimeFormatterprivate static classInstantFormatter.JavaDateTimeFormatterFactoryprivate static classInstantFormatter.Log4jFastFormatterprivate static classInstantFormatter.Log4jFastFormatterFactoryprivate static classInstantFormatter.Log4jFixedFormatterprivate static classInstantFormatter.Log4jFixedFormatterFactory
-
Field Summary
Fields Modifier and Type Field Description private InstantFormatter.Formatterformatterprivate static InstantFormatter.FormatterFactory[]FORMATTER_FACTORIESThe list of formatter factories in decreasing efficiency order.private static StatusLoggerLOGGER
-
Constructor Summary
Constructors Modifier Constructor Description privateInstantFormatter(InstantFormatter.Builder builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringformat(Instant instant)voidformat(Instant instant, java.lang.StringBuilder stringBuilder)java.lang.Class<?>getInternalImplementationClass()booleanisInstantMatching(Instant instant1, Instant instant2)Checks if the givenInstants are equal from the point of view of the employed formatter.static InstantFormatter.BuildernewBuilder()private static booleanpatternSupported(java.lang.String pattern, java.util.Locale locale, java.util.TimeZone timeZone, InstantFormatter.Formatter formatter)Checks if the provided formatter output matches with the one generated byDateTimeFormatter.
-
-
-
Field Detail
-
LOGGER
private static final StatusLogger LOGGER
-
FORMATTER_FACTORIES
private static final InstantFormatter.FormatterFactory[] FORMATTER_FACTORIES
The list of formatter factories in decreasing efficiency order.
-
formatter
private final InstantFormatter.Formatter formatter
-
-
Constructor Detail
-
InstantFormatter
private InstantFormatter(InstantFormatter.Builder builder)
-
-
Method Detail
-
format
public java.lang.String format(Instant instant)
-
format
public void format(Instant instant, java.lang.StringBuilder stringBuilder)
-
isInstantMatching
public boolean isInstantMatching(Instant instant1, Instant instant2)
Checks if the givenInstants are equal from the point of view of the employed formatter.This method should be preferred over
Instant#equals(Object). For instance,FixedDateFormatandFastDateFormatdiscard nanoseconds, hence, from their point of view, two differentInstants are equal if they match up to millisecond precision.
-
getInternalImplementationClass
public java.lang.Class<?> getInternalImplementationClass()
-
newBuilder
public static InstantFormatter.Builder newBuilder()
-
patternSupported
private static boolean patternSupported(java.lang.String pattern, java.util.Locale locale, java.util.TimeZone timeZone, InstantFormatter.Formatter formatter)Checks if the provided formatter output matches with the one generated byDateTimeFormatter.
-
-