}
int pos = parsePos.getIndex();
+ if(pos < 0) {
+ parsePos.setErrorIndex(0);
+ return;
+ }
int start = pos;
Output<TimeType> tzTimeType = new Output<TimeType>(TimeType.UNKNOWN);
// try 4/2/2, 3/2/2, 2/2/2, and finally 1/2/2.
if (numericFieldStart == -1) {
// check if this field is followed by abutting another numeric field
- if ((i + 1) < items.length
- && (items[i + 1] instanceof PatternItem)
+ if ((i + 1) < items.length
+ && (items[i + 1] instanceof PatternItem)
&& ((PatternItem)items[i + 1]).isNumeric) {
// record the first numeric field within a numeric text run
numericFieldStart = i;
}
}
+ public void TestT10906()
+ {
+ String pattern = new String("MM-dd-yyyy");
+ String text = new String("06-10-2014");
+ SimpleDateFormat format = new SimpleDateFormat(pattern);
+ ParsePosition pp = new ParsePosition(-1);
+ try {
+ format.parse(text, pp);
+ int errorIdx = pp.getErrorIndex();
+ if (errorIdx == -1) {
+ errln("failed to report invalid (negative) starting parse position");
+ }
+ } catch(StringIndexOutOfBoundsException e) {
+ errln("failed to fix invalid (negative) starting parse position");
+ }
+
+ }
+
}