public final class InstantFormatter extends Object
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.
Modifier and Type | Class and Description |
---|---|
static class |
InstantFormatter.Builder |
Modifier and Type | Method and Description |
---|---|
String |
format(Instant instant) |
void |
format(Instant instant,
StringBuilder stringBuilder) |
Class<?> |
getInternalImplementationClass() |
boolean |
isInstantMatching(Instant instant1,
Instant instant2)
Checks if the given
Instant s are equal from the point of view of
the employed formatter. |
static InstantFormatter.Builder |
newBuilder() |
public void format(Instant instant, StringBuilder stringBuilder)
public boolean isInstantMatching(Instant instant1, Instant instant2)
Instant
s are equal from the point of view of
the employed formatter.
This method should be preferred over Instant#equals(Object)
. For
instance, FixedDateFormat
and FastDateFormat
discard
nanoseconds, hence, from their point of view, two different
Instant
s are equal if they match up to millisecond precision.
public Class<?> getInternalImplementationClass()
public static InstantFormatter.Builder newBuilder()
Copyright © 1999-2022 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.