Search in sources :

Example 1 with DateFormat

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

the class DateView method updateClock.

protected void updateClock() {
    if (mDateFormat == null) {
        final Locale l = Locale.getDefault();
        DateFormat format = DateFormat.getInstanceForSkeleton(mDatePattern, l);
        format.setContext(DisplayContext.CAPITALIZATION_FOR_STANDALONE);
        mDateFormat = format;
    }
    mCurrentTime.setTime(System.currentTimeMillis());
    final String text = getDateFormat();
    if (!text.equals(mLastText)) {
        setText(text);
        mLastText = text;
    }
}
Also used : Locale(java.util.Locale) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(android.icu.text.DateFormat)

Example 2 with DateFormat

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

the class DateView method updateClock.

protected void updateClock() {
    if (mDateFormat == null) {
        final Locale l = Locale.getDefault();
        DateFormat format = DateFormat.getInstanceForSkeleton(mDatePattern, l);
        format.setContext(DisplayContext.CAPITALIZATION_FOR_STANDALONE);
        mDateFormat = format;
    }
    mCurrentTime.setTime(System.currentTimeMillis());
    final String text = mDateFormat.format(mCurrentTime);
    if (!text.equals(mLastText)) {
        setText(text);
        mLastText = text;
    }
}
Also used : Locale(java.util.Locale) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(android.icu.text.DateFormat)

Example 3 with DateFormat

use of android.icu.text.DateFormat in project android_frameworks_base by crdroidandroid.

the class DateView method updateClock.

protected void updateClock() {
    if (mDateFormat == null) {
        final Locale l = Locale.getDefault();
        DateFormat format = DateFormat.getInstanceForSkeleton(mDatePattern, l);
        format.setContext(DisplayContext.CAPITALIZATION_FOR_STANDALONE);
        mDateFormat = format;
    }
    mCurrentTime.setTime(System.currentTimeMillis());
    final String text = getDateFormat();
    if (!text.equals(mLastText)) {
        setText(text);
        mLastText = text;
    }
}
Also used : Locale(java.util.Locale) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(android.icu.text.DateFormat)

Example 4 with DateFormat

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

the class DateView method updateClock.

protected void updateClock() {
    if (mDateFormat == null) {
        final Locale l = Locale.getDefault();
        DateFormat format = DateFormat.getInstanceForSkeleton(mDatePattern, l);
        format.setContext(DisplayContext.CAPITALIZATION_FOR_STANDALONE);
        mDateFormat = format;
    }
    mCurrentTime.setTime(System.currentTimeMillis());
    final String text = getDateFormat();
    if (!text.equals(mLastText)) {
        setText(text);
        mLastText = text;
    }
}
Also used : Locale(java.util.Locale) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(android.icu.text.DateFormat)

Example 5 with DateFormat

use of android.icu.text.DateFormat in project robolectric by robolectric.

the class ShadowDateIntervalFormatTest method testDateInterval_FormatDateRange.

@Test
public void testDateInterval_FormatDateRange() throws ParseException {
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, 2013);
    calendar.set(Calendar.MONTH, Calendar.JANUARY);
    calendar.set(Calendar.DAY_OF_MONTH, 20);
    long timeInMillis = calendar.getTimeInMillis();
    String actual = DateIntervalFormat.formatDateRange(ULocale.getDefault(), TimeZone.getDefault(), timeInMillis, timeInMillis, DateUtils.FORMAT_NUMERIC_DATE);
    DateFormat format = new SimpleDateFormat("MM/dd/yyyy", ULocale.getDefault());
    Date date = format.parse(actual);
    assertThat(date).isNotNull();
}
Also used : Calendar(java.util.Calendar) DateFormat(android.icu.text.DateFormat) SimpleDateFormat(android.icu.text.SimpleDateFormat) SimpleDateFormat(android.icu.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test)

Aggregations

DateFormat (android.icu.text.DateFormat)97 SimpleDateFormat (android.icu.text.SimpleDateFormat)80 Test (org.junit.Test)78 Date (java.util.Date)67 GregorianCalendar (android.icu.util.GregorianCalendar)44 ChineseDateFormat (android.icu.text.ChineseDateFormat)37 Calendar (android.icu.util.Calendar)37 ULocale (android.icu.util.ULocale)33 JapaneseCalendar (android.icu.util.JapaneseCalendar)27 IslamicCalendar (android.icu.util.IslamicCalendar)23 ChineseCalendar (android.icu.util.ChineseCalendar)22 ParseException (java.text.ParseException)21 BuddhistCalendar (android.icu.util.BuddhistCalendar)19 TimeZone (android.icu.util.TimeZone)19 HebrewCalendar (android.icu.util.HebrewCalendar)17 Locale (java.util.Locale)17 ParsePosition (java.text.ParsePosition)15 FieldPosition (java.text.FieldPosition)13 IOException (java.io.IOException)10 SimpleTimeZone (android.icu.util.SimpleTimeZone)7