From d762a347fb6459d7b7c87d6f09a58b210400cb95 Mon Sep 17 00:00:00 2001 From: Erik Date: Fri, 1 Oct 2010 11:01:01 -0700 Subject: [PATCH] b/3054044 Make allDay event times format in utc AllDay events could get formatted with the local time zone instead of utc. This makes it so that using the utc flag in the wrapper for formatting correctly passes in UTC as the time zone. Change-Id: I65090ef939ce64c1a942c7683cf76a927c02cb53 --- core/java/android/util/CalendarUtils.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/java/android/util/CalendarUtils.java b/core/java/android/util/CalendarUtils.java index 3d340d99d1d6f..1b2a8943ca1d4 100644 --- a/core/java/android/util/CalendarUtils.java +++ b/core/java/android/util/CalendarUtils.java @@ -146,6 +146,9 @@ public class CalendarUtils { * This formats a date/time range using Calendar's time zone and the * local conventions for the region of the device. * + * If the {@link DateUtils#FORMAT_UTC} flag is used it will pass in + * the UTC time zone instead. + * * @param context the context is required only if the time is shown * @param startMillis the start time in UTC milliseconds * @param endMillis the end time in UTC milliseconds @@ -156,10 +159,16 @@ public class CalendarUtils { public String formatDateRange(Context context, long startMillis, long endMillis, int flags) { String date; + String tz; + if ((flags & DateUtils.FORMAT_UTC) != 0) { + tz = Time.TIMEZONE_UTC; + } else { + tz = getTimeZone(context, null); + } synchronized (mSB) { mSB.setLength(0); date = DateUtils.formatDateRange(context, mF, startMillis, endMillis, flags, - getTimeZone(context, null)).toString(); + tz).toString(); } return date; }