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 class
private static interface
private static interface
private static final class
private static final class
private static final class
private static final class
private static final class
private static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final InstantFormatter.Formatter
private static final InstantFormatter.FormatterFactory[]
The list of formatter factories in decreasing efficiency order. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
format
(Instant instant, StringBuilder stringBuilder) Class
<?> boolean
isInstantMatching
(Instant instant1, Instant instant2) Checks if the givenInstant
s are equal from the point of view of the employed formatter.static InstantFormatter.Builder
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
.
-
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 givenInstant
s are equal from the point of view of the employed formatter.This method should be preferred over
invalid reference
Instant#equals(Object)
FixedDateFormat
andFastDateFormat
discard nanoseconds, hence, from their point of view, two differentInstant
s 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
.
-