Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ba8d2e58 authored by Elliott Hughes's avatar Elliott Hughes Committed by Android Git Automerger
Browse files

am c2639e58: am 0bb4c701: Merge "Use ICU for getDateFormatOrder."

* commit 'c2639e58':
  Use ICU for getDateFormatOrder.
parents 4225d796 c2639e58
Loading
Loading
Loading
Loading
+2 −28
Original line number Diff line number Diff line
@@ -313,39 +313,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) {