You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2023/01/01 09:48:30 UTC

[GitHub] [logging-log4j2] ppkarwasz commented on a diff in pull request #1173: LOG4J2-1631 Honor timezone in file name pattern

ppkarwasz commented on code in PR #1173:
URL: https://github.com/apache/logging-log4j2/pull/1173#discussion_r1059727034


##########
log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/DatePatternConverter.java:
##########
@@ -52,6 +52,10 @@ private abstract static class Formatter {
         public String toPattern() {
             return null;
         }
+
+        public TimeZone getTimeZone() {
+            return null;
+        }

Review Comment:
   I would return `TimeZone.getDefault()` here to remove all null checks.



##########
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessor.java:
##########
@@ -343,6 +347,15 @@ private RolloverFrequency calculateFrequency(final String pattern) {
         return null;
     }
 
+    private static TimeZone calculateTimeZone(DatePatternConverter dateConverter) {
+        TimeZone timeZone = dateConverter.getTimeZone();
+        if (timeZone != null) {
+            return timeZone;
+        } else {
+            return Calendar.getInstance().getTimeZone();
+        }
+    }

Review Comment:
   If `getTimeZone()` didn't return `null`, this would be unnecessary.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org