src/share/classes/java/text/SimpleDateFormat.java

Print this page

        

@@ -1843,10 +1843,12 @@
             if (c != ' ' && c != '\t') {
                 break;
             }
             ++pos.index;
         }
+        // Remember the actual start index
+        int actualStart = pos.index;
 
       parsing:
         {
             // We handle a few special cases here where we need to parse
             // a number value.  We handle further, more generic cases below.  We need

@@ -1922,13 +1924,13 @@
                 // that the year value is to be treated literally, without any
                 // two-digit year adjustments (e.g., from "01" to 2001).  Otherwise
                 // we made adjustments to place the 2-digit year in the proper
                 // century, for parsed strings from "00" to "99".  Any other string
                 // is treated literally:  "2250", "-1", "1", "002".
-                if (count <= 2 && (pos.index - start) == 2
-                    && Character.isDigit(text.charAt(start))
-                    && Character.isDigit(text.charAt(start+1))) {
+                if (count <= 2 && (pos.index - actualStart) == 2
+                    && Character.isDigit(text.charAt(actualStart))
+                    && Character.isDigit(text.charAt(actualStart + 1))) {
                     // Assume for example that the defaultCenturyStart is 6/18/1903.
                     // This means that two-digit years will be forced into the range
                     // 6/18/1903 to 6/17/2003.  As a result, years 00, 01, and 02
                     // correspond to 2000, 2001, and 2002.  Years 04, 05, etc. correspond
                     // to 1904, 1905, etc.  If the year is 03, then it is 2003 if the