From cdafd37f3148dfc6f44f2e5de8b31adb6bf9e476 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 18 Mar 2013 17:21:33 -0700 Subject: Clean up (some of) our many clocks to use H instead of k. Bug: 8359981 Change-Id: I3c0c38c2bf5adc4b5bdc11c3d10cf41dd8fb6462 --- core/java/android/text/format/DateFormat.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'core/java/android/text/format') diff --git a/core/java/android/text/format/DateFormat.java b/core/java/android/text/format/DateFormat.java index c4e960a..50b1a29 100644 --- a/core/java/android/text/format/DateFormat.java +++ b/core/java/android/text/format/DateFormat.java @@ -170,9 +170,18 @@ public class DateFormat { * @return the {@link java.text.DateFormat} object that properly formats the time. */ public static java.text.DateFormat getTimeFormat(Context context) { + return new java.text.SimpleDateFormat(getTimeFormatString(context)); + } + + /** + * Returns a String pattern that can be used to format the time according + * to the current locale and the user's 12-/24-hour clock preference. + * @param context the application context + * @hide + */ + public static String getTimeFormatString(Context context) { LocaleData d = LocaleData.get(context.getResources().getConfiguration().locale); - boolean is24 = is24HourFormat(context); - return new java.text.SimpleDateFormat(is24 ? d.timeFormat24 : d.timeFormat12); + return is24HourFormat(context) ? d.timeFormat24 : d.timeFormat12; } /** -- cgit v1.1