Class InstantFormatter
java.lang.Object
org.apache.logging.log4j.layout.template.json.util.InstantFormatter
A composite
Instant formatter trying to employ either
FixedDateFormat, FastDateFormat, or DateTimeFormatter
in the given order due to performance reasons.
Note that FixedDateFormat and FastDateFormat only support
millisecond precision. If the pattern asks for a higher precision,
DateTimeFormatter will be employed, which is significantly slower.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classprivate static interfaceprivate static interfaceprivate static final classprivate static final classprivate static final classprivate static final classprivate static final classprivate static final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final InstantFormatter.Formatterprivate static final InstantFormatter.FormatterFactory[]The list of formatter factories in decreasing efficiency order. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidformat(Instant instant, StringBuilder stringBuilder) Class<?> booleanisInstantMatching(Instant instant1, Instant instant2) Checks if the givenInstants are equal from the point of view of the employed formatter.static InstantFormatter.Builderprivate static booleanpatternSupported(String pattern, Locale locale, TimeZone timeZone, InstantFormatter.Formatter formatter) Checks if the provided formatter output matches with the one generated byDateTimeFormatter.
-
Field Details
-
FORMATTER_FACTORIES
The list of formatter factories in decreasing efficiency order. -
formatter
-
-
Constructor Details
-
InstantFormatter
-
-
Method Details
-
format
-
format
-
isInstantMatching
Checks if the givenInstants are equal from the point of view of the employed formatter.This method should be preferred over
. For instance,invalid reference
Instant#equals(Object)FixedDateFormatandFastDateFormatdiscard nanoseconds, hence, from their point of view, two differentInstants are equal if they match up to millisecond precision. -
getInternalImplementationClass
-
newBuilder
-
patternSupported
private static boolean patternSupported(String pattern, Locale locale, TimeZone timeZone, InstantFormatter.Formatter formatter) Checks if the provided formatter output matches with the one generated byDateTimeFormatter.
-