const NumberFormat *
SimpleDateFormat::getNumberFormatForField(UChar field) const {
UDateFormatField index = DateFormatSymbols::getPatternCharIndex(field);
+ if (index == UDAT_FIELD_COUNT) {
+ return NULL;
+ }
return &getNumberFormatByIndex(index);
}
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2012, International Business Machines Corporation and
+ * Copyright (c) 1997-2014, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
if ((double)udDate == 0.0) {
errln("ERROR: Parsing failed using 'Y' and 'e'");
}
+
+// ====== Test ticket 11295 getNumberFormatForField returns wild pointer
+ if (object.getNumberFormatForField('B') != NULL) {
+ errln("B is not a valid field, "
+ "getNumberFormatForField should return NULL");
+ }
}
#endif /* #if !UCONFIG_NO_FORMATTING */