diff options
author | Erik <roboerik@android.com> | 2010-09-08 11:21:40 -0700 |
---|---|---|
committer | Erik <roboerik@android.com> | 2010-09-08 11:21:40 -0700 |
commit | 35d1362a75eac7cebbe9de23d08fea08c4aac817 (patch) | |
tree | 38cedc1e10c22fa51bacaeab59f4466256c58cad /src/com/android/calendar/Utils.java | |
parent | c497d7df6e1b8d88748e6691af3923c9be9be8e9 (diff) | |
parent | 864d1139b454dc11e62d3a9be56502e0eaca4012 (diff) | |
download | android_packages_apps_Calendar-35d1362a75eac7cebbe9de23d08fea08c4aac817.tar.gz android_packages_apps_Calendar-35d1362a75eac7cebbe9de23d08fea08c4aac817.tar.bz2 android_packages_apps_Calendar-35d1362a75eac7cebbe9de23d08fea08c4aac817.zip |
resolved conflicts for merge of 864d1139 to master
Change-Id: Id6c7daeccf202c6d0c73c8a536e09d39173288d4
Diffstat (limited to 'src/com/android/calendar/Utils.java')
-rw-r--r-- | src/com/android/calendar/Utils.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/com/android/calendar/Utils.java b/src/com/android/calendar/Utils.java index 1d80565e..44a2b04c 100644 --- a/src/com/android/calendar/Utils.java +++ b/src/com/android/calendar/Utils.java @@ -31,12 +31,15 @@ import android.graphics.drawable.GradientDrawable; import android.net.Uri; import android.os.Bundle; import android.text.TextUtils; +import android.text.format.DateUtils; import android.text.format.Time; import android.util.Log; import java.util.Calendar; +import java.util.Formatter; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.TimeZone; @@ -71,6 +74,9 @@ public class Utils { public static final String INTENT_KEY_VIEW_TYPE = "VIEW"; public static final String INTENT_VALUE_VIEW_TYPE_DAY = "DAY"; + private static StringBuilder mSB = new StringBuilder(50); + private static Formatter mF = new Formatter(mSB, Locale.getDefault()); + private volatile static boolean mFirstTZRequest = true; private volatile static boolean mTZQueryInProgress = false; @@ -188,6 +194,27 @@ public class Utils { return prefs.getString(key, defaultValue); } + /** + * Formats a date or a time range according to the local conventions. + * + * @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 + * @param flags a bit mask of options See + * {@link #formatDateRange(Context, Formatter, long, long, int, String) formatDateRange} + * @return a string containing the formatted date/time range. + */ + public static String formatDateRange(Context context, long startMillis, + long endMillis, int flags) { + String date; + synchronized (mSB) { + mSB.setLength(0); + date = DateUtils.formatDateRange(context, mF, startMillis, endMillis, flags, + getTimeZone(context, null)).toString(); + } + return date; + } + public static int getSharedPreference(Context context, String key, int defaultValue) { SharedPreferences prefs = CalendarPreferenceActivity.getSharedPreferences(context); return prefs.getInt(key, defaultValue); |