public class FixedDateFormat extends Object
FixedDateFormat.FixedFormat
. For any other date patterns use FastDateFormat
.
Related benchmarks: /log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/TimeFormatBenchmark.java and /log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ThreadsafeDateFormatBenchmark.java
Modifier and Type | Class and Description |
---|---|
static class |
FixedDateFormat.FixedFormat
Enumeration over the supported date/time format patterns.
|
static class |
FixedDateFormat.FixedTimeZoneFormat
Fixed time zone formats.
|
Modifier and Type | Method and Description |
---|---|
static FixedDateFormat |
create(FixedDateFormat.FixedFormat format)
Returns a new
FixedDateFormat object for the specified FixedFormat and a TimeZone.getDefault() TimeZone. |
static FixedDateFormat |
create(FixedDateFormat.FixedFormat format,
TimeZone tz)
Returns a new
FixedDateFormat object for the specified FixedFormat and TimeZone. |
static FixedDateFormat |
createIfSupported(String... options) |
String |
format(long epochMillis) |
int |
format(long epochMillis,
char[] buffer,
int startPos) |
String |
formatInstant(Instant instant) |
int |
formatInstant(Instant instant,
char[] buffer,
int startPos) |
String |
getFormat()
Returns the full pattern of the selected fixed format.
|
TimeZone |
getTimeZone()
Returns the time zone.
|
boolean |
isEquivalent(long oldEpochSecond,
int oldNanoOfSecond,
long epochSecond,
int nanoOfSecond)
Returns
true if the old and new date values will result in the same formatted output, false
if results may differ. |
long |
millisSinceMidnight(long currentTime)
Returns the number of milliseconds since midnight in the time zone that this
FixedDateFormat
was constructed with for the specified currentTime. |
public static FixedDateFormat createIfSupported(String... options)
public static FixedDateFormat create(FixedDateFormat.FixedFormat format)
FixedDateFormat
object for the specified FixedFormat
and a TimeZone.getDefault()
TimeZone.format
- the format to useFixedDateFormat
objectpublic static FixedDateFormat create(FixedDateFormat.FixedFormat format, TimeZone tz)
FixedDateFormat
object for the specified FixedFormat
and TimeZone.format
- the format to usetz
- the time zone to useFixedDateFormat
objectpublic String getFormat()
public TimeZone getTimeZone()
public long millisSinceMidnight(long currentTime)
Returns the number of milliseconds since midnight in the time zone that this FixedDateFormat
was constructed with for the specified currentTime.
As a side effect, this method updates the cached formatted date and the cached date demarcation timestamps when the specified current time is outside the previously set demarcation timestamps for the start or end of the current day.
currentTime
- the current time in millis since the epochpublic int formatInstant(Instant instant, char[] buffer, int startPos)
public String format(long epochMillis)
public int format(long epochMillis, char[] buffer, int startPos)
public boolean isEquivalent(long oldEpochSecond, int oldNanoOfSecond, long epochSecond, int nanoOfSecond)
true
if the old and new date values will result in the same formatted output, false
if results may differ. Copyright © 1999-2023 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.