Enum NamedInstantPattern
- All Implemented Interfaces:
Serializable,Comparable<NamedInstantPattern>,java.lang.constant.Constable
- Since:
- 2.26.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescription -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateNamedInstantPattern(String pattern) privateNamedInstantPattern(String pattern, String legacyPattern) -
Method Summary
Modifier and TypeMethodDescription(package private) StringReturns the legacyFixedDateFormatpattern associated with this named pattern.Returns the date-time pattern string compatible withDateTimeFormatterthat is associated with this named pattern.static NamedInstantPatternReturns the enum constant of this type with the specified name.static NamedInstantPattern[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
ABSOLUTE
-
ABSOLUTE_MICROS
-
ABSOLUTE_NANOS
-
ABSOLUTE_PERIOD
-
COMPACT
-
DATE
-
DATE_PERIOD
-
DEFAULT
-
DEFAULT_MICROS
-
DEFAULT_NANOS
-
DEFAULT_PERIOD
-
ISO8601_BASIC
-
ISO8601_BASIC_PERIOD
-
ISO8601
-
ISO8601_OFFSET_DATE_TIME_HH
-
ISO8601_OFFSET_DATE_TIME_HHMM
-
ISO8601_OFFSET_DATE_TIME_HHCMM
-
ISO8601_PERIOD
-
ISO8601_PERIOD_MICROS
-
US_MONTH_DAY_YEAR2_TIME
-
US_MONTH_DAY_YEAR4_TIME
-
-
Field Details
-
pattern
-
legacyPattern
-
-
Constructor Details
-
NamedInstantPattern
-
NamedInstantPattern
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
getPattern
Returns the date-time pattern string compatible withDateTimeFormatterthat is associated with this named pattern.- Returns:
- the date-time pattern string for use with
DateTimeFormatter
-
getLegacyPattern
String getLegacyPattern()Returns the legacyFixedDateFormatpattern associated with this named pattern.If legacy formatters are enabled, output is produced for
FixedDateFormatandFastDateFormat. To convert theDateTimeFormatterto its legacy counterpart, the following transformations need to be applied:Pattern Differences Microseconds Nanoseconds Time-zone Legacy formatter directive nnnnnnnnnnnnnnnX,XX,XXXDateTimeFormatterdirectiveSSSSSSSSSSSSSSSx,xx,xxxRationale
-
Legacy formatters are largely compatible with the
SimpleDateFormatspecification, but introduce a customnpattern letter, unique to Log4j, to represent sub-millisecond precision. Thisnis not part of the standardSimpleDateFormat.In legacy formatters, repeating
nincreases the precision, similar to how repeatedSis used for fractional seconds inDateTimeFormatter.In contrast,
DateTimeFormatterinterpretsnas nano-of-second. In Java 17, bothnandNalways output nanosecond precision, regardless of the number of pattern letters. -
Legacy formatters use
X,XX, andXXXto format time zones as+00,+0000, or+00:00, followingSimpleDateFormatconventions. In contrast,DateTimeFormatteroutputsZfor zero-offset when usingX. To ensure numeric output for zero-offset (e.g.,+00), we usex,xx, orxxxinstead.
- Returns:
- the legacy pattern string as used in
FixedDateFormat.FixedFormat
-
-