jdk/src/share/classes/java/text/SimpleDateFormat.java
changeset 18146 47760e45a1dd
parent 17178 bf3ea41ef154
child 19054 a64012cb49d6
equal deleted inserted replaced
18145:39484c6a0c61 18146:47760e45a1dd
  1843             if (c != ' ' && c != '\t') {
  1843             if (c != ' ' && c != '\t') {
  1844                 break;
  1844                 break;
  1845             }
  1845             }
  1846             ++pos.index;
  1846             ++pos.index;
  1847         }
  1847         }
       
  1848         // Remember the actual start index
       
  1849         int actualStart = pos.index;
  1848 
  1850 
  1849       parsing:
  1851       parsing:
  1850         {
  1852         {
  1851             // We handle a few special cases here where we need to parse
  1853             // We handle a few special cases here where we need to parse
  1852             // a number value.  We handle further, more generic cases below.  We need
  1854             // a number value.  We handle further, more generic cases below.  We need
  1922                 // that the year value is to be treated literally, without any
  1924                 // that the year value is to be treated literally, without any
  1923                 // two-digit year adjustments (e.g., from "01" to 2001).  Otherwise
  1925                 // two-digit year adjustments (e.g., from "01" to 2001).  Otherwise
  1924                 // we made adjustments to place the 2-digit year in the proper
  1926                 // we made adjustments to place the 2-digit year in the proper
  1925                 // century, for parsed strings from "00" to "99".  Any other string
  1927                 // century, for parsed strings from "00" to "99".  Any other string
  1926                 // is treated literally:  "2250", "-1", "1", "002".
  1928                 // is treated literally:  "2250", "-1", "1", "002".
  1927                 if (count <= 2 && (pos.index - start) == 2
  1929                 if (count <= 2 && (pos.index - actualStart) == 2
  1928                     && Character.isDigit(text.charAt(start))
  1930                     && Character.isDigit(text.charAt(actualStart))
  1929                     && Character.isDigit(text.charAt(start+1))) {
  1931                     && Character.isDigit(text.charAt(actualStart + 1))) {
  1930                     // Assume for example that the defaultCenturyStart is 6/18/1903.
  1932                     // Assume for example that the defaultCenturyStart is 6/18/1903.
  1931                     // This means that two-digit years will be forced into the range
  1933                     // This means that two-digit years will be forced into the range
  1932                     // 6/18/1903 to 6/17/2003.  As a result, years 00, 01, and 02
  1934                     // 6/18/1903 to 6/17/2003.  As a result, years 00, 01, and 02
  1933                     // correspond to 2000, 2001, and 2002.  Years 04, 05, etc. correspond
  1935                     // correspond to 2000, 2001, and 2002.  Years 04, 05, etc. correspond
  1934                     // to 1904, 1905, etc.  If the year is 03, then it is 2003 if the
  1936                     // to 1904, 1905, etc.  If the year is 03, then it is 2003 if the