Search in sources :

Example 16 with DateFormatSymbols

use of android.icu.text.DateFormatSymbols in project j2objc by google.

the class IntlTestDateFormatSymbols method TestConstructorWithCalendar.

@Test
public void TestConstructorWithCalendar() {
    ULocale[] TestLocales = { new ULocale("en_US@calendar=gregorian"), new ULocale("ja_JP@calendar=japanese"), new ULocale("th_TH@calendar=buddhist"), new ULocale("zh_TW@calendar=roc"), new ULocale("ar_IR@calendar=persian"), new ULocale("ar_EG@calendar=islamic"), new ULocale("he_IL@calendar=hebrew"), new ULocale("zh_CN@calendar=chinese"), new ULocale("hi_IN@calendar=indian"), new ULocale("ar_EG@calendar=coptic"), new ULocale("am_ET@calendar=ethiopic") };
    int i;
    // calendars
    Calendar[] calendars = new Calendar[TestLocales.length];
    for (i = 0; i < TestLocales.length; i++) {
        calendars[i] = Calendar.getInstance(TestLocales[i]);
    }
    // Creates an instance from a base locale + calendar
    DateFormatSymbols[] symbols = new DateFormatSymbols[TestLocales.length];
    for (i = 0; i < TestLocales.length; i++) {
        symbols[i] = new DateFormatSymbols(calendars[i], new ULocale(TestLocales[i].getBaseName()));
    }
    // with an instance created from its base locale + calendar class
    for (i = 0; i < TestLocales.length; i++) {
        DateFormatSymbols dfs = new DateFormatSymbols(calendars[i].getClass(), new ULocale(TestLocales[i].getBaseName()));
        if (!dfs.equals(symbols[i])) {
            errln("FAIL: DateFormatSymbols created from a base locale and calendar instance" + " is different from one created from the same base locale and calendar class - " + TestLocales[i]);
        }
    }
}
Also used : ULocale(android.icu.util.ULocale) Calendar(android.icu.util.Calendar) DateFormatSymbols(android.icu.text.DateFormatSymbols) Test(org.junit.Test)

Example 17 with DateFormatSymbols

use of android.icu.text.DateFormatSymbols in project j2objc by google.

the class ChineseTest method TestScratch.

@Test
public void TestScratch() {
    String[] strMonths = { "Januari", "Pebruari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "Nopember", "Desember" };
    String[] strShortMonths = { "Jan", "Peb", "Mar", "Apr", "Mei", "Jun", "Jul", "Agt", "Sep", "Okt", "Nop", "Des" };
    String[] strWeeks = { "", "Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu" };
    DateFormatSymbols dfsDate = new DateFormatSymbols(new Locale("id", "ID"));
    dfsDate.setMonths(strMonths);
    dfsDate.setShortMonths(strShortMonths);
    dfsDate.setWeekdays(strWeeks);
    ULocale uloInd = dfsDate.getLocale(ULocale.ACTUAL_LOCALE);
    if (uloInd == null) {
        errln("did not get the expected ULocale");
    }
    logln(uloInd.toString());
    Locale locInd = uloInd.toLocale();
    if (locInd == null) {
        errln("did not get the expected result");
    }
    logln(locInd.toString());
}
Also used : Locale(java.util.Locale) ULocale(android.icu.util.ULocale) ULocale(android.icu.util.ULocale) DateFormatSymbols(android.icu.text.DateFormatSymbols) Test(org.junit.Test)

Aggregations

DateFormatSymbols (android.icu.text.DateFormatSymbols)17 Test (org.junit.Test)14 ULocale (android.icu.util.ULocale)7 SimpleDateFormat (android.icu.text.SimpleDateFormat)6 Calendar (android.icu.util.Calendar)5 Date (java.util.Date)5 ChineseDateFormatSymbols (android.icu.text.ChineseDateFormatSymbols)4 BuddhistCalendar (android.icu.util.BuddhistCalendar)4 ChineseCalendar (android.icu.util.ChineseCalendar)4 GregorianCalendar (android.icu.util.GregorianCalendar)4 JapaneseCalendar (android.icu.util.JapaneseCalendar)4 FieldPosition (java.text.FieldPosition)4 ParseException (java.text.ParseException)4 Locale (java.util.Locale)4 ChineseDateFormat (android.icu.text.ChineseDateFormat)3 DateFormat (android.icu.text.DateFormat)3 HebrewCalendar (android.icu.util.HebrewCalendar)3 IslamicCalendar (android.icu.util.IslamicCalendar)3 IOException (java.io.IOException)3 TimeZone (android.icu.util.TimeZone)2