[
https://issues.apache.org/jira/browse/LOG4J2-1246?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16709487#comment-16709487
]
Remko Popma commented on LOG4J2-1246:
-------------------------------------
I missed this in my initial review, but the "X" in the constant names give the
users very little hints about what the resulting format will be.
Javadoc is on the nested {{FixedTimeZoneFormat}} enum but not on the
{{FixedFormat}} new enum values.
Could we rename these constants:
* FixedTimeZoneFormat.X ->> FixedTimeZoneFormat.HH
* FixedTimeZoneFormat.XX ->> FixedTimeZoneFormat.HHMM
* FixedTimeZoneFormat.XXX ->> FixedTimeZoneFormat.HH_MM
* FixedTimeZoneFormat.Z ->> FixedTimeZoneFormat.Z (as is)
Also rename the new FixedFormat constants and perhaps add some javadoc on how
this will get rendered in the log file:
{code}
/**
* ISO8601_OFFSET_DATE_TIME_HH time format: {@code
"yyyy-MM-dd'T'HH:mm:ss,SSSHH"}, rendered as {@code
"yyyy-MM-dd'T'HH:mm:ss,SSS±HH"}.
*/
ISO8601_OFFSET_DATE_TIME_HH("yyyy-MM-dd'T'HH:mm:ss,SSSHH", "yyyy-MM-dd'T'", 2,
':', 1, ',', 1, 3, FixedTimeZoneFormat.HH),
/**
* ISO8601_OFFSET_DATE_TIME_HHMM time format: {@code
"yyyy-MM-dd'T'HH:mm:ss,SSSHHMM"}, rendered as {@code
"yyyy-MM-dd'T'HH:mm:ss,SSS±HHMM"}.
*/
ISO8601_OFFSET_DATE_TIME_HHMM("yyyy-MM-dd'T'HH:mm:ss,SSSHHMM", "yyyy-MM-dd'T'",
2, ':', 1, ',', 1, 3, FixedTimeZoneFormat.HHMM),
/**
* ISO8601_OFFSET_DATE_TIME_HH_MM time format: {@code
"yyyy-MM-dd'T'HH:mm:ss,SSSHH_MM"} rendered as {@code
"yyyy-MM-dd'T'HH:mm:ss,SSS±HH:MM".
*/
ISO8601_OFFSET_DATE_TIME_HH_MM("yyyy-MM-dd'T'HH:mm:ss,SSSHH_MM",
"yyyy-MM-dd'T'", 2, ':', 1, ',', 1, 3, FixedTimeZoneFormat.HH_MM),
/**
* ISO8601_OFFSET_DATE_TIME_Z time format: {@code "yyyy-MM-dd'T'HH:mm:ss,SSSZ"}
rendered as {@code "yyyy-MM-dd'T'HH:mm:ss,SSSZ"}.
*/
ISO8601_OFFSET_DATE_TIME_Z("yyyy-MM-dd'T'HH:mm:ss,SSSZ", "yyyy-MM-dd'T'", 2,
':', 1, ',', 1, 3, FixedTimeZoneFormat.Z),
{code}
> PatternLayout %date conversion pattern should render time zone designator for
> ISO-ISO8601
> -----------------------------------------------------------------------------------------
>
> Key: LOG4J2-1246
> URL: https://issues.apache.org/jira/browse/LOG4J2-1246
> Project: Log4j 2
> Issue Type: Bug
> Components: Pattern Converters
> Affects Versions: 2.4.1, 2.5
> Reporter: Daniel Marcotte
> Priority: Major
> Fix For: 2.11.2
>
>
> Hi there!
> There might be a small issue with the Pattern Converters regarding Timezone
> management:
> http://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout
> Right now, these patterns:
> * {{"%d\{ISO8601_BASIC\}}}
> * {{%d\{ISO8601_BASIC\}\{UTC\}}}
> Give the same results:
> * {{20160104T204256,048}}
> * {{20160104T204256,048}}
> However, with a deeper look at the ISO-8601 standards, the second one with
> {{"\{UTC\}"}} should properly add the Timezone at the end of the timestamp.
> Reference: https://en.wikipedia.org/wiki/ISO_8601#Times
> {quote}
> *UTC*
> If the time is in UTC, add a Z directly after the time without a space. Z is
> the zone designator for the zero UTC offset. "09:30 UTC" is therefore
> represented as "09:30Z" or "0930Z". "14:45:15 UTC" would be "14:45:15Z" or
> "144515Z".
> UTC time is also known as 'Zulu' time, since 'Zulu' is the NATO phonetic
> alphabet word for 'Z'.
> *Examples*
> <time>Z
> <time>±hh:mm
> <time>±hhmm
> <time>±hh
> {quote}
> As of ISO-8601, the results should be one of the following (configurable?):
> * {{20160104T204256,048Z}}
> * {{20160104T204256,048+00:00}}
> * {{20160104T204256,048+0000}}
> * {{20160104T204256,048+00}}
> Another reference:
> http://stackoverflow.com/questions/833102/wheres-the-datetime-z-format-specifier
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)