]> granicus.if.org Git - icu/commitdiff
ICU-9399 return correct parse index when an era is expected but something else is...
authorPeter Edberg <pedberg@unicode.org>
Tue, 28 Aug 2012 03:40:07 +0000 (03:40 +0000)
committerPeter Edberg <pedberg@unicode.org>
Tue, 28 Aug 2012 03:40:07 +0000 (03:40 +0000)
X-SVN-Rev: 32262

icu4c/source/i18n/smpdtfmt.cpp
icu4c/source/test/intltest/dtfmttst.cpp

index 985c95215b9adbf4be919dc62c3f429522f4e874..f5daecf4778ff83e09786ee52fa52378d396820e 100644 (file)
@@ -1749,7 +1749,8 @@ SimpleDateFormat::parse(const UnicodeString& text, Calendar& cal, ParsePosition&
 
                 if (s == -pos-1) {
                     // era not present, in special cases allow this to continue
-                    s++;
+                    // from the position where the era was expected
+                    s = pos;
 
                     if (i+1 < fPattern.length()) {
                         // move to next pattern character
index 15a101a207ade83daeae32defa22437932cec4b0..5ba26595d502f478e5ab2a7be4957c1cdb4048b5 100644 (file)
@@ -3673,6 +3673,8 @@ void DateFormatTest::TestParsePosition() {
         {"vvvv a h:mm:ss", "", "Pacific Time AM 10:21:45", ""},
         {"HH:mm v M/d", "111", "14:15 PT 8/10", " 12345"},
         {"'time zone:' VVVV 'date:' yyyy-MM-dd", "xxxx", "time zone: United States Time (Los Angeles) date: 2010-02-25", "xxxx"},
+        {"yG", "", "2012AD", ""},
+        {"yG", "", "2012", "x"},
         {0, 0, 0, 0},
     };