diff options
author | Elliott Hughes <enh@google.com> | 2013-08-14 15:12:43 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2013-08-14 15:12:43 -0700 |
commit | f0b79aeed36f0839e4effaa36893b7ca71292563 (patch) | |
tree | ce4f5634a4db4e38e2c5a0b6ded598c8db258b24 | |
parent | a0b320a66f6467107edac57f3f41471d9d550507 (diff) | |
download | base-f0b79aeed36f0839e4effaa36893b7ca71292563.tar.gz |
DateUtils should use the user's 12/24-hour preference, not the locale's.
Bug: 10312832
Change-Id: If23c124cf8442988de5feccb6f2c40b808a2eb89
-rw-r--r-- | core/java/android/text/format/DateUtils.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/core/java/android/text/format/DateUtils.java b/core/java/android/text/format/DateUtils.java index cba350fa598f..2b805a9bc367 100644 --- a/core/java/android/text/format/DateUtils.java +++ b/core/java/android/text/format/DateUtils.java @@ -815,7 +815,13 @@ public class DateUtils * @return the formatter with the formatted date/time range appended to the string buffer. */ public static Formatter formatDateRange(Context context, Formatter formatter, long startMillis, - long endMillis, int flags, String timeZone) { + long endMillis, int flags, String timeZone) { + // icu4c will fall back to the locale's preferred 12/24 format, + // but we want to fall back to the user's preference. + if ((flags & (FORMAT_12HOUR | FORMAT_24HOUR)) == 0) { + flags |= DateFormat.is24HourFormat(context) ? FORMAT_24HOUR : FORMAT_12HOUR; + } + String range = DateIntervalFormat.formatDateRange(startMillis, endMillis, flags, timeZone); try { formatter.out().append(range); |