Class InstantFormatter
- java.lang.Object
-
- org.apache.logging.log4j.layout.template.json.util.InstantFormatter
-
public final class InstantFormatter extends Object
A 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.Builder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringformat(Instant instant)voidformat(Instant instant, StringBuilder stringBuilder)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()
-
-
-
Method Detail
-
format
public void format(Instant instant, 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 Class<?> getInternalImplementationClass()
-
newBuilder
public static InstantFormatter.Builder newBuilder()
-
-