diff options
| author | Adam Powell <adamp@google.com> | 2010-03-23 17:32:41 -0700 |
|---|---|---|
| committer | Adam Powell <adamp@google.com> | 2010-03-23 17:32:41 -0700 |
| commit | f3311c940aee73afb0eeeedde4799e45f544dbc3 (patch) | |
| tree | 9551005ef0a0e95747c0d1045762d6fe5b324510 /core/java/android/widget/DateTimeView.java | |
| parent | a06150b2a0b26f8471ee63c50fc6259f2d1563d0 (diff) | |
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
Diffstat (limited to 'core/java/android/widget/DateTimeView.java')
| -rw-r--r-- | core/java/android/widget/DateTimeView.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/core/java/android/widget/DateTimeView.java b/core/java/android/widget/DateTimeView.java index 3dab9f2127e2..6b845b049ff7 100644 --- a/core/java/android/widget/DateTimeView.java +++ b/core/java/android/widget/DateTimeView.java @@ -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); + } } } |
