diff --git a/src/com/android/email/Email.java b/src/com/android/email/Email.java index ad06daeb5..08efba737 100644 --- a/src/com/android/email/Email.java +++ b/src/com/android/email/Email.java @@ -143,6 +143,11 @@ public class Email extends Application { public static final int FETCHING_EMAIL_NOTIFICATION_ID = -4; public static final int FETCHING_EMAIL_NOTIFICATION_MULTI_ACCOUNT_ID = -1; public static final int FETCHING_EMAIL_NOTIFICATION_NO_ACCOUNT = -2; + + // Backup formats in case they can't be fetched from the system + public static final String BACKUP_DATE_FORMAT = "MM-dd-yyyy"; + public static final String TIME_FORMAT_12 = "h:mm a"; + public static final String TIME_FORMAT_24 = "H:mm"; /** * Called throughout the application when the number of accounts has changed. This method diff --git a/src/com/android/email/activity/FolderMessageList.java b/src/com/android/email/activity/FolderMessageList.java index e702610d6..c38ca73bb 100644 --- a/src/com/android/email/activity/FolderMessageList.java +++ b/src/com/android/email/activity/FolderMessageList.java @@ -148,7 +148,15 @@ public class FolderMessageList extends ExpandableListActivity { if (dateFormat == null) { - dateFormat = android.pim.DateFormat.getDateFormat(getApplication()); + String dateFormatS = android.provider.Settings.System.getString(getContentResolver(), + android.provider.Settings.System.DATE_FORMAT); + if (dateFormatS != null) { + dateFormat = new java.text.SimpleDateFormat(dateFormatS); + } + else + { + dateFormat = new java.text.SimpleDateFormat(Email.BACKUP_DATE_FORMAT); + } } return dateFormat; } @@ -156,8 +164,11 @@ public class FolderMessageList extends ExpandableListActivity private DateFormat getTimeFormat() { if (timeFormat == null) - { - timeFormat = android.pim.DateFormat.getTimeFormat(getApplication()); + { + String timeFormatS = android.provider.Settings.System.getString(getContentResolver(), + android.provider.Settings.System.TIME_12_24); + boolean b24 = !(timeFormatS == null || timeFormatS.equals("12")); + timeFormat = new java.text.SimpleDateFormat(b24 ? Email.TIME_FORMAT_24 : Email.TIME_FORMAT_12); } return timeFormat; } diff --git a/src/com/android/email/activity/MessageView.java b/src/com/android/email/activity/MessageView.java index 4ed91553c..3c55aecbb 100644 --- a/src/com/android/email/activity/MessageView.java +++ b/src/com/android/email/activity/MessageView.java @@ -100,18 +100,29 @@ public class MessageView extends Activity private DateFormat getDateFormat() { - if (dateFormat == null) - { - dateFormat = android.pim.DateFormat.getDateFormat(getApplication()); - } + if (dateFormat == null) + { + String dateFormatS = android.provider.Settings.System.getString(getContentResolver(), + android.provider.Settings.System.DATE_FORMAT); + if (dateFormatS != null) { + dateFormat = new java.text.SimpleDateFormat(dateFormatS); + } + else + { + dateFormat = new java.text.SimpleDateFormat(Email.BACKUP_DATE_FORMAT); + } + } return dateFormat; } private DateFormat getTimeFormat() { - if (timeFormat == null) - { - timeFormat = android.pim.DateFormat.getTimeFormat(getApplication()); - } + if (timeFormat == null) + { + String timeFormatS = android.provider.Settings.System.getString(getContentResolver(), + android.provider.Settings.System.TIME_12_24); + boolean b24 = !(timeFormatS == null || timeFormatS.equals("12")); + timeFormat = new java.text.SimpleDateFormat(b24 ? Email.TIME_FORMAT_24 : Email.TIME_FORMAT_12); + } return timeFormat; } private void clearFormats()