Class DatePatternConverter
java.lang.Object
org.apache.logging.log4j.core.pattern.AbstractPatternConverter
org.apache.logging.log4j.core.pattern.LogEventPatternConverter
org.apache.logging.log4j.core.pattern.DatePatternConverter
- All Implemented Interfaces:
ArrayPatternConverter,PatternConverter
@Plugin(name="DatePatternConverter",
category="Converter")
@NullMarked
public final class DatePatternConverter
extends LogEventPatternConverter
implements ArrayPatternConverter
Converts and formats the event's date in a StringBuilder.
-
Field Summary
FieldsFields inherited from class org.apache.logging.log4j.core.pattern.AbstractPatternConverter
LOGGERFields inherited from interface org.apache.logging.log4j.core.pattern.PatternConverter
CATEGORY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static InstantFormattercreateFormatter(@Nullable String[] options) private static InstantFormattercreateFormatterUnsafely(@Nullable String[] options) (package private) static StringdecodeNamedPattern(String pattern) DecodesFixedDateFormatnamed patterns into their correspondingDateTimeFormatterrepresentations.voidformat(long epochMillis, StringBuilder buffer) Deprecated.voidformat(@Nullable Object object, StringBuilder buffer) Formats an object into a string buffer.voidformat(StringBuilder buffer, @Nullable Object... objects) Formats an array of Objects.voidformat(Date date, StringBuilder buffer) Deprecated.Starting with version2.25.0, this method is deprecated and planned to be removed in the next major release.voidformat(LogEvent event, StringBuilder output) Formats an event into a string buffer.voidformat(Instant instant, StringBuilder buffer) Deprecated.Starting with version2.25.0, this method is deprecated and planned to be removed in the next major release.private static voidlogOptionReadFailure(String[] options, Exception error, String message) static DatePatternConverternewInstance(String[] options) Obtains an instance of pattern converter.private static LocalereadLocale(@Nullable String[] options) private static StringreadPattern(@Nullable String[] options) private static TimeZonereadTimeZone(@Nullable String[] options) Methods inherited from class org.apache.logging.log4j.core.pattern.LogEventPatternConverter
emptyVariableOutput, handlesThrowable, isVariableMethods inherited from class org.apache.logging.log4j.core.pattern.AbstractPatternConverter
getName, getStyleClassMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.logging.log4j.core.pattern.PatternConverter
getName, getStyleClass
-
Field Details
-
CLASS_NAME
-
formatter
-
-
Constructor Details
-
DatePatternConverter
-
-
Method Details
-
createFormatter
-
createFormatterUnsafely
-
readPattern
-
decodeNamedPattern
DecodesFixedDateFormatnamed patterns into their correspondingDateTimeFormatterrepresentations.In version
2.25.0,FixedDateFormatandFastDateFormatare deprecated in favor ofInstantPatternFormatter. We introduced this method to keep backward compatibility with the named patterns provided byFixedDateFormat.- Parameters:
pattern- a user provided date invalid input: '&' time formatting pattern- Returns:
- the transformed formatting pattern where
FixedDateFormatnamed patterns are replaced with their correspondingDateTimeFormatterrepresentations - Since:
- 2.25.0
-
readTimeZone
-
readLocale
-
logOptionReadFailure
-
newInstance
Obtains an instance of pattern converter.- Parameters:
options- options, may be null.- Returns:
- instance of pattern converter.
-
format
Deprecated.Starting with version2.25.0, this method is deprecated and planned to be removed in the next major release.Formats the given date to the provided buffer.- Parameters:
date- a datebuffer- a buffer to append to
-
format
Description copied from class:LogEventPatternConverterFormats an event into a string buffer.- Specified by:
formatin classLogEventPatternConverter- Parameters:
event- event to format, may not be null.output- string buffer to which the formatted event will be appended. May not be null.
-
format
Deprecated.Starting with version2.25.0, this method is deprecated and planned to be removed in the next major release.Formats the given epoch milliseconds to the provided buffer.- Parameters:
epochMillis- epoch millisecondsbuffer- a buffer to append to
-
format
Deprecated.Starting with version2.25.0, this method is deprecated and planned to be removed in the next major release.Formats the given instant to the provided buffer.- Parameters:
instant- an instantbuffer- a buffer to append to
-
format
Description copied from class:LogEventPatternConverterFormats an object into a string buffer.- Specified by:
formatin interfacePatternConverter- Overrides:
formatin classLogEventPatternConverter- Parameters:
object- event to format, may not be null.buffer- string buffer to which the formatted event will be appended. May not be null.
-
format
Description copied from interface:ArrayPatternConverterFormats an array of Objects.- Specified by:
formatin interfaceArrayPatternConverter- Parameters:
buffer- The StringBuilder to add the content to.objects- The Object array.
-
getPattern
- Returns:
- the pattern string describing this date format or
nullif the format does not have a pattern.
-
getTimeZone
- Returns:
- the time zone used by this date format
-
2.25.0, this method is deprecated and planned to be removed in the next major release.