k150000, sdf.parse(UnicodeString("2015-11-13 03:00 noon"), errorCode));
}
+void DateFormatTest::TestParseRegression13744() {
+ LocalPointer<DateFormat> dfmt(DateFormat::createDateTimeInstance(
+ DateFormat::SHORT, DateFormat::SHORT, Locale("en", "US")));
+ ParsePosition pos(0);
+ UnicodeString inDate("4/27/18");
+ dfmt->parse(inDate, pos);
+ assertEquals("Error index", inDate.length(), pos.getErrorIndex());
+}
+
#endif /* #if !UCONFIG_NO_FORMATTING */
//eof
void TestDayPeriodWithLocales();
void TestMinuteSecondFieldsInOddPlaces();
void TestDayPeriodParsing();
+ void TestParseRegression13744();
private:
UBool showParse(DateFormat &format, const UnicodeString &formattedString);
char afterType = ((PatternItem) after).type;
if (DATE_PATTERN_TYPE.contains(beforeType) != DATE_PATTERN_TYPE.contains(afterType)) {
int newPos = originalPos;
- while (true) {
+ while (newPos < tlen) {
char ich = text.charAt(newPos);
if (!PatternProps.isWhiteSpace(ich)) {
break;
assertEquals("yyyy-MM-dd hh:mm b | 2015-11-13 03:00 midnight", k030000, sdf.parse("2015-11-13 03:00 midnight"));
assertEquals("yyyy-MM-dd hh:mm b | 2015-11-13 03:00 noon", k150000, sdf.parse("2015-11-13 03:00 noon"));
}
+
+ @Test
+ public void TestParseRegression13744() {
+ DateFormat dfmt = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.US);
+ ParsePosition pos = new ParsePosition(0);
+ final String inDate = "4/27/18"; // date only, no time
+ dfmt.parse(inDate, pos);
+ assertEquals("Error index", inDate.length(), pos.getErrorIndex());
+ }
}