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 2022/07/10 20:26:07 UTC

[GitHub] [logging-log4j2] jaystyles commented on a diff in pull request #244: New iso date time formats

jaystyles commented on code in PR #244:
URL: https://github.com/apache/logging-log4j2/pull/244#discussion_r917442746


##########
log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FixedDateFormat.java:
##########
@@ -183,16 +218,27 @@ static FixedFormat lookupIgnoringNanos(final String pattern) {
             return null;
         }
 
-        private static int nanoStart(final String pattern) {
-            final int index = pattern.indexOf(SECOND_FRACTION_PATTERN);
-            if (index >= 0) {
-                for (int i = index + 1; i < pattern.length(); i++) {
+        private final static int[] EMPTY_RANGE = { -1, -1 };
+        
+        /**
+         * 
+         * @param pattern
+         * @return int[0] start index inclusive; int[1] end index exclusive
+         */
+        private static int[] nanoRange(final String pattern) {
+            final int indexStart = pattern.indexOf(SECOND_FRACTION_PATTERN);
+            int indexEnd = -1;
+            if (indexStart >= 0) {
+                indexEnd = pattern.indexOf('Z', indexStart);
+                indexEnd = indexEnd < 0 ? pattern.indexOf('X', indexStart) : indexEnd;
+                indexEnd = indexEnd < 0 ? pattern.length() : indexEnd; 
+                for (int i = indexStart + 1; i < indexEnd; i++) {
                     if (pattern.charAt(i) != SECOND_FRACTION_PATTERN) {
-                        return -1;
+                        return EMPTY_RANGE;
                     }
                 }
             }
-            return index;
+            return new int [] {indexStart, indexEnd};

Review Comment:
   @Dependabot merge



-- 
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