diff options
author | Elliott Hughes <enh@google.com> | 2013-04-30 18:22:18 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2013-04-30 18:22:18 +0000 |
commit | 0bb4c701bab0f69172417b7a511acb6bdfa052db (patch) | |
tree | b2f066336d3dbee84e33022de8f5b49dd73afa23 /core | |
parent | 1f6e789b7ee9698ab8c528a393c28cce500ace04 (diff) | |
parent | edd6f9e688698da4f6ba9da5e56a5546f9162200 (diff) | |
download | frameworks_base-0bb4c701bab0f69172417b7a511acb6bdfa052db.zip frameworks_base-0bb4c701bab0f69172417b7a511acb6bdfa052db.tar.gz frameworks_base-0bb4c701bab0f69172417b7a511acb6bdfa052db.tar.bz2 |
Merge "Use ICU for getDateFormatOrder."
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/text/format/DateFormat.java | 31 |
1 files changed, 3 insertions, 28 deletions
diff --git a/core/java/android/text/format/DateFormat.java b/core/java/android/text/format/DateFormat.java index 50b1a29..ff5106a 100644 --- a/core/java/android/text/format/DateFormat.java +++ b/core/java/android/text/format/DateFormat.java @@ -31,6 +31,7 @@ import java.util.Locale; import java.util.TimeZone; import java.text.SimpleDateFormat; +import libcore.icu.ICU; import libcore.icu.LocaleData; /** @@ -278,39 +279,13 @@ public class DateFormat { * Gets the current date format stored as a char array. The array will contain * 3 elements ({@link #DATE}, {@link #MONTH}, and {@link #YEAR}) in the order * specified by the user's format preference. Note that this order is - * only appropriate for all-numeric dates; spelled-out (MEDIUM and LONG) + * <i>only</i> appropriate for all-numeric dates; spelled-out (MEDIUM and LONG) * dates will generally contain other punctuation, spaces, or words, * not just the day, month, and year, and not necessarily in the same * order returned here. */ public static char[] getDateFormatOrder(Context context) { - char[] order = new char[] {DATE, MONTH, YEAR}; - String value = getDateFormatString(context); - int index = 0; - boolean foundDate = false; - boolean foundMonth = false; - boolean foundYear = false; - - for (char c : value.toCharArray()) { - if (!foundDate && (c == DATE)) { - foundDate = true; - order[index] = DATE; - index++; - } - - if (!foundMonth && (c == MONTH || c == STANDALONE_MONTH)) { - foundMonth = true; - order[index] = MONTH; - index++; - } - - if (!foundYear && (c == YEAR)) { - foundYear = true; - order[index] = YEAR; - index++; - } - } - return order; + return ICU.getDateFormatOrder(getDateFormatString(context)); } private static String getDateFormatString(Context context) { |