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") public final class DatePatternConverter extends LogEventPatternConverter implements ArrayPatternConverter
Converts and formats the event's date in a StringBuilder.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classDatePatternConverter.CachedTimeprivate static classDatePatternConverter.FixedFormatterprivate static classDatePatternConverter.Formatterprivate static classDatePatternConverter.PatternFormatterprivate static classDatePatternConverter.UnixFormatterprivate static classDatePatternConverter.UnixMillisFormatter
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicReference<DatePatternConverter.CachedTime>cachedTimeprivate DatePatternConverter.Formatterformatterprivate java.lang.String[]optionsprivate java.lang.ThreadLocal<DatePatternConverter.Formatter>threadLocalFormatterprivate java.lang.ThreadLocal<MutableInstant>threadLocalMutableInstantprivate static java.lang.StringUNIX_FORMATUNIX formatter in seconds (standard).private static java.lang.StringUNIX_MILLIS_FORMATUNIX formatter in milliseconds-
Fields inherited from class org.apache.logging.log4j.core.pattern.AbstractPatternConverter
LOGGER
-
Fields inherited from interface org.apache.logging.log4j.core.pattern.PatternConverter
CATEGORY
-
-
Constructor Summary
Constructors Modifier Constructor Description privateDatePatternConverter(java.lang.String[] options)Private constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static DatePatternConverter.FormattercreateFixedFormatter(FixedDateFormat fixedDateFormat)private DatePatternConverter.FormattercreateFormatter(java.lang.String[] options)private static DatePatternConverter.FormattercreateNonFixedFormatter(java.lang.String[] options)voidformat(long epochMilli, java.lang.StringBuilder output)voidformat(java.lang.Object obj, java.lang.StringBuilder output)Formats an object into a string buffer.voidformat(java.lang.StringBuilder toAppendTo, java.lang.Object... objects)Formats an array of Objects.voidformat(java.util.Date date, java.lang.StringBuilder toAppendTo)Appends formatted date to string buffer.voidformat(LogEvent event, java.lang.StringBuilder output)Formats an event into a string buffer.voidformat(Instant instant, java.lang.StringBuilder output)private voidformatWithoutAllocation(Instant instant, java.lang.StringBuilder output)private voidformatWithoutThreadLocals(Instant instant, java.lang.StringBuilder output)private DatePatternConverter.CachedTimefromEpochMillis(long epochMillis)private MutableInstantgetMutableInstant()java.lang.StringgetPattern()Gets the pattern string describing this date format.private DatePatternConverter.FormattergetThreadLocalFormatter()java.util.TimeZonegetTimeZone()Gets the timezone used by this date format.static DatePatternConverternewInstance(java.lang.String[] options)Obtains an instance of pattern converter.-
Methods inherited from class org.apache.logging.log4j.core.pattern.LogEventPatternConverter
handlesThrowable, isVariable
-
Methods inherited from class org.apache.logging.log4j.core.pattern.AbstractPatternConverter
getName, getStyleClass
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.logging.log4j.core.pattern.PatternConverter
getName, getStyleClass
-
-
-
-
Field Detail
-
UNIX_FORMAT
private static final java.lang.String UNIX_FORMAT
UNIX formatter in seconds (standard).- See Also:
- Constant Field Values
-
UNIX_MILLIS_FORMAT
private static final java.lang.String UNIX_MILLIS_FORMAT
UNIX formatter in milliseconds- See Also:
- Constant Field Values
-
options
private final java.lang.String[] options
-
threadLocalMutableInstant
private final java.lang.ThreadLocal<MutableInstant> threadLocalMutableInstant
-
threadLocalFormatter
private final java.lang.ThreadLocal<DatePatternConverter.Formatter> threadLocalFormatter
-
cachedTime
private final java.util.concurrent.atomic.AtomicReference<DatePatternConverter.CachedTime> cachedTime
-
formatter
private final DatePatternConverter.Formatter formatter
-
-
Method Detail
-
fromEpochMillis
private DatePatternConverter.CachedTime fromEpochMillis(long epochMillis)
-
createFormatter
private DatePatternConverter.Formatter createFormatter(java.lang.String[] options)
-
newInstance
public static DatePatternConverter newInstance(java.lang.String[] options)
Obtains an instance of pattern converter.- Parameters:
options- options, may be null.- Returns:
- instance of pattern converter.
-
createFixedFormatter
private static DatePatternConverter.Formatter createFixedFormatter(FixedDateFormat fixedDateFormat)
-
createNonFixedFormatter
private static DatePatternConverter.Formatter createNonFixedFormatter(java.lang.String[] options)
-
format
public void format(java.util.Date date, java.lang.StringBuilder toAppendTo)Appends formatted date to string buffer.- Parameters:
date- datetoAppendTo- buffer to which formatted date is appended.
-
format
public void format(LogEvent event, java.lang.StringBuilder output)
Formats 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
public void format(long epochMilli, java.lang.StringBuilder output)
-
getMutableInstant
private MutableInstant getMutableInstant()
-
format
public void format(Instant instant, java.lang.StringBuilder output)
-
formatWithoutAllocation
private void formatWithoutAllocation(Instant instant, java.lang.StringBuilder output)
-
getThreadLocalFormatter
private DatePatternConverter.Formatter getThreadLocalFormatter()
-
formatWithoutThreadLocals
private void formatWithoutThreadLocals(Instant instant, java.lang.StringBuilder output)
-
format
public void format(java.lang.Object obj, java.lang.StringBuilder output)Formats an object into a string buffer.- Specified by:
formatin interfacePatternConverter- Overrides:
formatin classLogEventPatternConverter- Parameters:
obj- event to format, may not be null.output- string buffer to which the formatted event will be appended. May not be null.
-
format
public void format(java.lang.StringBuilder toAppendTo, java.lang.Object... objects)Description copied from interface:ArrayPatternConverterFormats an array of Objects.- Specified by:
formatin interfaceArrayPatternConverter- Parameters:
toAppendTo- The StringBuilder to add the content to.objects- The Object array.
-
getPattern
public java.lang.String getPattern()
Gets the pattern string describing this date format.- Returns:
- the pattern string describing this date format.
-
getTimeZone
public java.util.TimeZone getTimeZone()
Gets the timezone used by this date format.- Returns:
- the timezone used by this date format.
-
-