Search in sources :

Example 1 with SimpleDateFormat

use of android.icu.text.SimpleDateFormat in project android_frameworks_base by ResurrectionRemix.

the class DatePickerCalendarDelegate method onLocaleChanged.

@Override
protected void onLocaleChanged(Locale locale) {
    final TextView headerYear = mHeaderYear;
    if (headerYear == null) {
        // again later after everything has been set up.
        return;
    }
    // Update the date formatter.
    final String datePattern = DateFormat.getBestDateTimePattern(locale, "EMMMd");
    mMonthDayFormat = new SimpleDateFormat(datePattern, locale);
    mMonthDayFormat.setContext(DisplayContext.CAPITALIZATION_FOR_STANDALONE);
    mYearFormat = new SimpleDateFormat("y", locale);
    // Clear out the lazily-initialized accessibility event formatter.
    mAccessibilityEventFormat = null;
    // Update the header text.
    onCurrentDateChanged(false);
}
Also used : SimpleDateFormat(android.icu.text.SimpleDateFormat)

Example 2 with SimpleDateFormat

use of android.icu.text.SimpleDateFormat in project android_frameworks_base by DirtyUnicorns.

the class SimpleMonthView method updateMonthYearLabel.

private void updateMonthYearLabel() {
    final String format = DateFormat.getBestDateTimePattern(mLocale, MONTH_YEAR_FORMAT);
    final SimpleDateFormat formatter = new SimpleDateFormat(format, mLocale);
    formatter.setContext(DisplayContext.CAPITALIZATION_FOR_STANDALONE);
    mMonthYearLabel = formatter.format(mCalendar.getTime());
}
Also used : SimpleDateFormat(android.icu.text.SimpleDateFormat)

Example 3 with SimpleDateFormat

use of android.icu.text.SimpleDateFormat in project android_frameworks_base by AOSPA.

the class DatePickerCalendarDelegate method onLocaleChanged.

@Override
protected void onLocaleChanged(Locale locale) {
    final TextView headerYear = mHeaderYear;
    if (headerYear == null) {
        // again later after everything has been set up.
        return;
    }
    // Update the date formatter.
    final String datePattern = DateFormat.getBestDateTimePattern(locale, "EMMMd");
    mMonthDayFormat = new SimpleDateFormat(datePattern, locale);
    mMonthDayFormat.setContext(DisplayContext.CAPITALIZATION_FOR_STANDALONE);
    mYearFormat = new SimpleDateFormat("y", locale);
    // Clear out the lazily-initialized accessibility event formatter.
    mAccessibilityEventFormat = null;
    // Update the header text.
    onCurrentDateChanged(false);
}
Also used : SimpleDateFormat(android.icu.text.SimpleDateFormat)

Example 4 with SimpleDateFormat

use of android.icu.text.SimpleDateFormat in project platform_frameworks_base by android.

the class DatePickerCalendarDelegate method onLocaleChanged.

@Override
protected void onLocaleChanged(Locale locale) {
    final TextView headerYear = mHeaderYear;
    if (headerYear == null) {
        // again later after everything has been set up.
        return;
    }
    // Update the date formatter.
    final String datePattern = DateFormat.getBestDateTimePattern(locale, "EMMMd");
    mMonthDayFormat = new SimpleDateFormat(datePattern, locale);
    mMonthDayFormat.setContext(DisplayContext.CAPITALIZATION_FOR_STANDALONE);
    mYearFormat = new SimpleDateFormat("y", locale);
    // Clear out the lazily-initialized accessibility event formatter.
    mAccessibilityEventFormat = null;
    // Update the header text.
    onCurrentDateChanged(false);
}
Also used : SimpleDateFormat(android.icu.text.SimpleDateFormat)

Example 5 with SimpleDateFormat

use of android.icu.text.SimpleDateFormat in project platform_frameworks_base by android.

the class DatePickerCalendarDelegate method onPopulateAccessibilityEvent.

@Override
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
    if (mAccessibilityEventFormat == null) {
        final String pattern = DateFormat.getBestDateTimePattern(mCurrentLocale, "EMMMMdy");
        mAccessibilityEventFormat = new SimpleDateFormat(pattern);
    }
    final CharSequence text = mAccessibilityEventFormat.format(mCurrentDate.getTime());
    event.getText().add(text);
}
Also used : SimpleDateFormat(android.icu.text.SimpleDateFormat)

Aggregations

SimpleDateFormat (android.icu.text.SimpleDateFormat)153 Test (org.junit.Test)113 Date (java.util.Date)103 GregorianCalendar (android.icu.util.GregorianCalendar)59 Calendar (android.icu.util.Calendar)53 ParseException (java.text.ParseException)42 DateFormat (android.icu.text.DateFormat)41 JapaneseCalendar (android.icu.util.JapaneseCalendar)41 ULocale (android.icu.util.ULocale)40 IslamicCalendar (android.icu.util.IslamicCalendar)37 ParsePosition (java.text.ParsePosition)36 FieldPosition (java.text.FieldPosition)29 ChineseCalendar (android.icu.util.ChineseCalendar)27 TimeZone (android.icu.util.TimeZone)27 BuddhistCalendar (android.icu.util.BuddhistCalendar)25 ChineseDateFormat (android.icu.text.ChineseDateFormat)21 HebrewCalendar (android.icu.util.HebrewCalendar)21 IOException (java.io.IOException)19 SimpleTimeZone (android.icu.util.SimpleTimeZone)16 Locale (java.util.Locale)14