From: Peter Edberg Date: Tue, 28 Aug 2012 03:40:07 +0000 (+0000) Subject: ICU-9399 return correct parse index when an era is expected but something else is... X-Git-Tag: milestone-59-0-1~3626 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8db60a2d2bb983499ad1336d3f4ffa47f2d80809;p=icu ICU-9399 return correct parse index when an era is expected but something else is found X-SVN-Rev: 32262 --- diff --git a/icu4c/source/i18n/smpdtfmt.cpp b/icu4c/source/i18n/smpdtfmt.cpp index 985c95215b9..f5daecf4778 100644 --- a/icu4c/source/i18n/smpdtfmt.cpp +++ b/icu4c/source/i18n/smpdtfmt.cpp @@ -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 diff --git a/icu4c/source/test/intltest/dtfmttst.cpp b/icu4c/source/test/intltest/dtfmttst.cpp index 15a101a207a..5ba26595d50 100644 --- a/icu4c/source/test/intltest/dtfmttst.cpp +++ b/icu4c/source/test/intltest/dtfmttst.cpp @@ -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}, };