Fix bug 2531732 - DateTimeView explodes on bad system date format.

Fall back to a default date format instead of throwing an exception.

Change-Id: I827a81d9610ea7f9243c1c33579e7a5d3b423692
This commit is contained in:
Adam Powell
2010-03-23 17:32:41 -07:00
parent a06150b2a0
commit f3311c940a

View File

@@ -206,7 +206,12 @@ public class DateTimeView extends TextView {
if (format == null || "".equals(format)) {
return DateFormat.getDateInstance(DateFormat.SHORT);
} else {
return new SimpleDateFormat(format);
try {
return new SimpleDateFormat(format);
} catch (IllegalArgumentException e) {
// If we tried to use a bad format string, fall back to a default.
return DateFormat.getDateInstance(DateFormat.SHORT);
}
}
}