Class InstantFormatter
- java.lang.Object
-
- org.apache.logging.log4j.layout.template.json.util.InstantFormatter
-
public final class InstantFormatter extends Object
A compositeInstant
formatter trying to employ eitherFixedDateFormat
,FastDateFormat
, orDateTimeFormatter
in the given order due to performance reasons.Note that
FixedDateFormat
andFastDateFormat
only support millisecond precision. If the pattern asks for a higher precision,DateTimeFormatter
will be employed, which is significantly slower.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
InstantFormatter.Builder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
format(Instant instant)
void
format(Instant instant, StringBuilder stringBuilder)
Class<?>
getInternalImplementationClass()
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
newBuilder()
-
-
-
Method Detail
-
format
public void format(Instant instant, StringBuilder stringBuilder)
-
isInstantMatching
public boolean isInstantMatching(Instant instant1, Instant instant2)
Checks if the givenInstant
s are equal from the point of view of the employed formatter.This method should be preferred over
Instant#equals(Object)
. For instance,FixedDateFormat
andFastDateFormat
discard nanoseconds, hence, from their point of view, two differentInstant
s are equal if they match up to millisecond precision.
-
getInternalImplementationClass
public Class<?> getInternalImplementationClass()
-
newBuilder
public static InstantFormatter.Builder newBuilder()
-
-