DateUtils should use the user's 12/24-hour preference, not the locale's.

Bug: 10312832

(cherry picked from commit f0b79aeed3)

Change-Id: I0d78725d47009553f9003ccfba06f70f178a6ec1
This commit is contained in:
Elliott Hughes
2013-08-14 15:12:43 -07:00
parent 66a83ae650
commit 12285f3d9f

View File

@@ -815,7 +815,13 @@ public class DateUtils
* @return the formatter with the formatted date/time range appended to the string buffer. * @return the formatter with the formatted date/time range appended to the string buffer.
*/ */
public static Formatter formatDateRange(Context context, Formatter formatter, long startMillis, 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); String range = DateIntervalFormat.formatDateRange(startMillis, endMillis, flags, timeZone);
try { try {
formatter.out().append(range); formatter.out().append(range);