Search in sources :

Example 6 with JapaneseCalendar

use of android.icu.util.JapaneseCalendar in project j2objc by google.

the class GlobalizationPreferencesTest method TestDateFormat.

@Test
public void TestDateFormat() {
    GlobalizationPreferences gp = new GlobalizationPreferences();
    String pattern;
    DateFormat df;
    // Set unsupported locale - ach
    logln("Set locale - ach");
    gp.setLocale(new ULocale("ach"));
    // Date - short
    df = gp.getDateFormat(GlobalizationPreferences.DF_SHORT, GlobalizationPreferences.DF_NONE);
    pattern = ((SimpleDateFormat) df).toPattern();
    // root pattern must be used
    if (!pattern.equals("y-MM-dd")) {
        errln("FAIL: SHORT date pattern is " + pattern + " Expected: y-MM-dd");
    }
    // Set locale - fr, fr_CA, fr_FR
    ArrayList lcls = new ArrayList(3);
    lcls.add(new ULocale("fr"));
    lcls.add(new ULocale("fr_CA"));
    lcls.add(new ULocale("fr_FR"));
    logln("Set locales - fr, fr_CA, fr_FR");
    gp.setLocales(lcls);
    // Date - short
    df = gp.getDateFormat(GlobalizationPreferences.DF_SHORT, GlobalizationPreferences.DF_NONE);
    pattern = ((SimpleDateFormat) df).toPattern();
    // fr_CA pattern must be used
    if (!pattern.equals("yy-MM-dd")) {
        errln("FAIL: SHORT date pattern is " + pattern + " Expected: yy-MM-dd");
    }
    // Set locale - en_GB
    logln("Set locale - en_GB");
    gp.setLocale(new ULocale("en_GB"));
    // Date - full
    df = gp.getDateFormat(GlobalizationPreferences.DF_FULL, GlobalizationPreferences.DF_NONE);
    pattern = ((SimpleDateFormat) df).toPattern();
    if (!pattern.equals("EEEE, d MMMM y")) {
        errln("FAIL: FULL date pattern is " + pattern + " Expected: EEEE, d MMMM y");
    }
    // Date - long
    df = gp.getDateFormat(GlobalizationPreferences.DF_LONG, GlobalizationPreferences.DF_NONE);
    pattern = ((SimpleDateFormat) df).toPattern();
    if (!pattern.equals("d MMMM y")) {
        errln("FAIL: LONG date pattern is " + pattern + " Expected: d MMMM y");
    }
    // Date - medium
    df = gp.getDateFormat(GlobalizationPreferences.DF_MEDIUM, GlobalizationPreferences.DF_NONE);
    pattern = ((SimpleDateFormat) df).toPattern();
    if (!pattern.equals("d MMM y")) {
        errln("FAIL: MEDIUM date pattern is " + pattern + " Expected: d MMM y");
    }
    // Date - short
    df = gp.getDateFormat(GlobalizationPreferences.DF_SHORT, GlobalizationPreferences.DF_NONE);
    pattern = ((SimpleDateFormat) df).toPattern();
    if (!pattern.equals("dd/MM/y")) {
        errln("FAIL: SHORT date pattern is " + pattern + " Expected: dd/MM/y");
    }
    // Time - full
    df = gp.getDateFormat(GlobalizationPreferences.DF_NONE, GlobalizationPreferences.DF_FULL);
    pattern = ((SimpleDateFormat) df).toPattern();
    if (!pattern.equals("HH:mm:ss zzzz")) {
        errln("FAIL: FULL time pattern is " + pattern + " Expected: HH:mm:ss zzzz");
    }
    // Time - long
    df = gp.getDateFormat(GlobalizationPreferences.DF_NONE, GlobalizationPreferences.DF_LONG);
    pattern = ((SimpleDateFormat) df).toPattern();
    if (!pattern.equals("HH:mm:ss z")) {
        errln("FAIL: LONG time pattern is " + pattern + " Expected: HH:mm:ss z");
    }
    // Time - medium
    df = gp.getDateFormat(GlobalizationPreferences.DF_NONE, GlobalizationPreferences.DF_MEDIUM);
    pattern = ((SimpleDateFormat) df).toPattern();
    if (!pattern.equals("HH:mm:ss")) {
        errln("FAIL: MEDIUM time pattern is " + pattern + " Expected: HH:mm:ss");
    }
    // Time - short
    df = gp.getDateFormat(GlobalizationPreferences.DF_NONE, GlobalizationPreferences.DF_SHORT);
    pattern = ((SimpleDateFormat) df).toPattern();
    if (!pattern.equals("HH:mm")) {
        errln("FAIL: SHORT time pattern is " + pattern + " Expected: HH:mm");
    }
    // Date/Time - full
    df = gp.getDateFormat(GlobalizationPreferences.DF_FULL, GlobalizationPreferences.DF_FULL);
    pattern = ((SimpleDateFormat) df).toPattern();
    if (!pattern.equals("EEEE, d MMMM y 'at' HH:mm:ss zzzz")) {
        errln("FAIL: FULL date/time pattern is " + pattern + " Expected: EEEE, d MMMM y 'at' HH:mm:ss zzzz");
    }
    // Invalid style
    boolean illegalArg = false;
    try {
        df = gp.getDateFormat(-1, GlobalizationPreferences.DF_NONE);
    } catch (IllegalArgumentException iae) {
        logln("Illegal date style -1");
        illegalArg = true;
    }
    if (!illegalArg) {
        errln("FAIL: getDateFormat() must throw IllegalArgumentException for dateStyle -1");
    }
    illegalArg = false;
    try {
        df = gp.getDateFormat(GlobalizationPreferences.DF_NONE, GlobalizationPreferences.DF_NONE);
    } catch (IllegalArgumentException iae) {
        logln("Illegal style - dateStyle:DF_NONE / timeStyle:DF_NONE");
        illegalArg = true;
    }
    if (!illegalArg) {
        errln("FAIL: getDateFormat() must throw IllegalArgumentException for dateStyle:DF_NONE/timeStyle:DF_NONE");
    }
    // Set explicit time zone
    logln("Set timezone - America/Sao_Paulo");
    TimeZone tz = TimeZone.getTimeZone("America/Sao_Paulo");
    gp.setTimeZone(tz);
    df = gp.getDateFormat(GlobalizationPreferences.DF_LONG, GlobalizationPreferences.DF_MEDIUM);
    String tzid = df.getTimeZone().getID();
    if (!tzid.equals("America/Sao_Paulo")) {
        errln("FAIL: The DateFormat instance must use timezone America/Sao_Paulo");
    }
    // Set explicit calendar
    logln("Set calendar - japanese");
    Calendar jcal = new JapaneseCalendar();
    jcal.setTimeZone(TimeZone.getTimeZone("Asia/Tokyo"));
    gp.setCalendar(jcal);
    df = gp.getDateFormat(GlobalizationPreferences.DF_SHORT, GlobalizationPreferences.DF_SHORT);
    Calendar dfCal = df.getCalendar();
    if (!(dfCal instanceof JapaneseCalendar)) {
        errln("FAIL: The DateFormat instance must use Japanese calendar");
    }
    // TimeZone must be still America/Sao_Paulo
    tzid = df.getTimeZone().getID();
    if (!tzid.equals("America/Sao_Paulo")) {
        errln("FAIL: The DateFormat instance must use timezone America/Sao_Paulo");
    }
    // Set explicit DateFormat
    logln("Set explicit date format - full date");
    DateFormat customFD = DateFormat.getDateInstance(new IslamicCalendar(), DateFormat.FULL, new ULocale("ar_SA"));
    customFD.setTimeZone(TimeZone.getTimeZone("Asia/Riyadh"));
    gp.setDateFormat(GlobalizationPreferences.DF_FULL, GlobalizationPreferences.DF_NONE, customFD);
    df = gp.getDateFormat(GlobalizationPreferences.DF_FULL, GlobalizationPreferences.DF_NONE);
    dfCal = df.getCalendar();
    if (!(dfCal instanceof IslamicCalendar)) {
        errln("FAIL: The DateFormat instance must use Islamic calendar");
    }
    // TimeZone in the custom DateFormat is overridden by GP's timezone setting
    tzid = df.getTimeZone().getID();
    if (!tzid.equals("America/Sao_Paulo")) {
        errln("FAIL: The DateFormat instance must use timezone America/Sao_Paulo");
    }
    // Freeze
    logln("Freeze this object");
    gp.freeze();
    DateFormat customLD = DateFormat.getDateInstance(new BuddhistCalendar(), DateFormat.LONG, new ULocale("th"));
    customLD.setTimeZone(TimeZone.getTimeZone("Asia/Bangkok"));
    boolean isFrozen = false;
    try {
        gp.setDateFormat(GlobalizationPreferences.DF_LONG, GlobalizationPreferences.DF_NONE, customLD);
    } catch (UnsupportedOperationException uoe) {
        logln("setDateFormat is blocked");
        isFrozen = true;
    }
    if (!isFrozen) {
        errln("FAIL: setDateFormat must be blocked after frozen");
    }
    // Modifiable clone
    logln("cloneAsThawed");
    GlobalizationPreferences gp1 = (GlobalizationPreferences) gp.cloneAsThawed();
    gp1.setDateFormat(GlobalizationPreferences.DF_LONG, GlobalizationPreferences.DF_NONE, customLD);
    df = gp1.getDateFormat(GlobalizationPreferences.DF_SHORT, GlobalizationPreferences.DF_SHORT);
    dfCal = df.getCalendar();
    if (!(dfCal instanceof JapaneseCalendar)) {
        errln("FAIL: The DateFormat instance must use Japanese calendar");
    }
    // TimeZone must be still America/Sao_Paulo
    tzid = df.getTimeZone().getID();
    if (!tzid.equals("America/Sao_Paulo")) {
        errln("FAIL: The DateFormat instance must use timezone America/Sao_Paulo");
    }
    df = gp1.getDateFormat(GlobalizationPreferences.DF_LONG, GlobalizationPreferences.DF_NONE);
    dfCal = df.getCalendar();
    if (!(dfCal instanceof BuddhistCalendar)) {
        errln("FAIL: The DateFormat instance must use Buddhist calendar");
    }
    // TimeZone must be still America/Sao_Paulo
    tzid = df.getTimeZone().getID();
    if (!tzid.equals("America/Sao_Paulo")) {
        errln("FAIL: The DateFormat instance must use timezone America/Sao_Paulo");
    }
}
Also used : GlobalizationPreferences(android.icu.util.GlobalizationPreferences) ULocale(android.icu.util.ULocale) IslamicCalendar(android.icu.util.IslamicCalendar) GregorianCalendar(android.icu.util.GregorianCalendar) BuddhistCalendar(android.icu.util.BuddhistCalendar) Calendar(android.icu.util.Calendar) JapaneseCalendar(android.icu.util.JapaneseCalendar) ArrayList(java.util.ArrayList) JapaneseCalendar(android.icu.util.JapaneseCalendar) TimeZone(android.icu.util.TimeZone) BuddhistCalendar(android.icu.util.BuddhistCalendar) DateFormat(android.icu.text.DateFormat) SimpleDateFormat(android.icu.text.SimpleDateFormat) IslamicCalendar(android.icu.util.IslamicCalendar) Test(org.junit.Test)

Example 7 with JapaneseCalendar

use of android.icu.util.JapaneseCalendar in project j2objc by google.

the class IBMCalendarTest method TestJapanese.

/**
 * Verify that JapaneseCalendar shifts years to Japanese Eras but otherwise
 * behaves like GregorianCalendar.
 */
@Test
public void TestJapanese() {
    // First make sure this test works for GregorianCalendar
    int[] control = { GregorianCalendar.AD, 1868, 1868, Calendar.SEPTEMBER, 8, GregorianCalendar.AD, 1868, 1868, Calendar.SEPTEMBER, 9, GregorianCalendar.AD, 1869, 1869, Calendar.JUNE, 4, GregorianCalendar.AD, 1912, 1912, Calendar.JULY, 29, GregorianCalendar.AD, 1912, 1912, Calendar.JULY, 30, GregorianCalendar.AD, 1912, 1912, Calendar.AUGUST, 1 };
    quasiGregorianTest(new GregorianCalendar(), control);
    int[] data = { JapaneseCalendar.MEIJI, 1, 1868, Calendar.SEPTEMBER, 8, JapaneseCalendar.MEIJI, 1, 1868, Calendar.SEPTEMBER, 9, JapaneseCalendar.MEIJI, 2, 1869, Calendar.JUNE, 4, JapaneseCalendar.MEIJI, 45, 1912, Calendar.JULY, 29, JapaneseCalendar.TAISHO, 1, 1912, Calendar.JULY, 30, JapaneseCalendar.TAISHO, 1, 1912, Calendar.AUGUST, 1 };
    quasiGregorianTest(new JapaneseCalendar(), data);
}
Also used : GregorianCalendar(android.icu.util.GregorianCalendar) JapaneseCalendar(android.icu.util.JapaneseCalendar) Test(org.junit.Test)

Example 8 with JapaneseCalendar

use of android.icu.util.JapaneseCalendar in project j2objc by google.

the class DateFormatRegressionTest method TestHindiArabicDigits.

@Test
public void TestHindiArabicDigits() {
    String s;
    char first;
    String what;
    {
        DateFormat df = DateFormat.getInstance(new GregorianCalendar(), new ULocale("hi_IN@numbers=deva"));
        what = "Gregorian Calendar, hindi";
        s = df.format(new Date(0));
        /* 31/12/1969 */
        logln(what + "=" + s);
        first = s.charAt(0);
        if (first < kHindiZero || first > (kHindiZero + 9)) {
            errln(what + "- wrong digit,  got " + s + " (integer digit value " + new Integer((int) first).toString());
        }
    }
    {
        DateFormat df = DateFormat.getInstance(new IslamicCalendar(), new Locale("ar", "IQ"));
        s = df.format(new Date(0));
        /* 21/10/1989 */
        what = "Islamic Calendar, Arabic";
        logln(what + ": " + s);
        first = s.charAt(0);
        if (first < kArabicZero || first > (kArabicZero + 9)) {
            errln(what + " wrong digit, got " + s + " (integer digit value " + new Integer((int) first).toString());
        }
    }
    {
        DateFormat df = DateFormat.getInstance(new GregorianCalendar(), new Locale("ar", "IQ"));
        s = df.format(new Date(0));
        /* 31/12/1969 */
        what = "Gregorian,  ar_IQ, df.getInstance";
        logln(what + ": " + s);
        first = s.charAt(0);
        if (first < kArabicZero || first > (kArabicZero + 9)) {
            errln(what + " wrong  digit but got " + s + " (integer digit value " + new Integer((int) first).toString());
        }
    }
    {
        DateFormat df = DateFormat.getInstance(new GregorianCalendar(), new Locale("mt", "MT"));
        s = df.format(new Date(0));
        /* 31/12/1969 */
        what = "Gregorian,  mt_MT, df.getInstance";
        logln(what + ": " + s);
        first = s.charAt(0);
        if (first < kLatinZero || first > (kLatinZero + 9)) {
            errln(what + " wrong  digit but got " + s + " (integer digit value " + new Integer((int) first).toString());
        }
    }
    {
        DateFormat df = DateFormat.getInstance(new IslamicCalendar(), new Locale("ar", "IQ"));
        s = df.format(new Date(0));
        /* 31/12/1969 */
        what = "Islamic calendar, ar_IQ, df.getInstance";
        logln(what + ": " + s);
        first = s.charAt(0);
        if (first < kArabicZero || first > (kArabicZero + 9)) {
            errln(what + " wrong  digit but got " + s + " (integer digit value " + new Integer((int) first).toString());
        }
    }
    {
        DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, new Locale("ar", "IQ"));
        s = df.format(new Date(0));
        /* 31/12/1969 */
        what = "ar_IQ, getDateTimeInstance";
        logln(what + ": " + s);
        first = s.charAt(0);
        if (first < kArabicZero || first > (kArabicZero + 9)) {
            errln(what + " wrong  digit but got " + s + " (integer digit value " + new Integer((int) first).toString());
        }
    }
    {
        DateFormat df = DateFormat.getInstance(new JapaneseCalendar(), new Locale("ar", "IQ"));
        s = df.format(new Date(0));
        /* 31/12/1969 */
        what = "ar_IQ, Japanese Calendar, getInstance";
        logln(what + ": " + s);
        first = s.charAt(0);
        if (first < kArabicZero || first > (kArabicZero + 9)) {
            errln(what + " wrong  digit but got " + s + " (integer digit value " + new Integer((int) first).toString());
        }
    }
}
Also used : ULocale(android.icu.util.ULocale) Locale(java.util.Locale) ULocale(android.icu.util.ULocale) DateFormat(android.icu.text.DateFormat) SimpleDateFormat(android.icu.text.SimpleDateFormat) GregorianCalendar(android.icu.util.GregorianCalendar) Date(java.util.Date) JapaneseCalendar(android.icu.util.JapaneseCalendar) IslamicCalendar(android.icu.util.IslamicCalendar) Test(org.junit.Test)

Example 9 with JapaneseCalendar

use of android.icu.util.JapaneseCalendar in project j2objc by google.

the class DateFormatTest method TestRoundtripWithCalendar.

/*
     * Test for format/parse method with calendar which is different
     * from what DateFormat instance internally use.  See ticket#6420.
     */
@Test
public void TestRoundtripWithCalendar() {
    TimeZone tz = TimeZone.getTimeZone("Europe/Paris");
    TimeZone gmt = TimeZone.getTimeZone("Etc/GMT");
    final Calendar[] calendars = { new GregorianCalendar(tz), new BuddhistCalendar(tz), new HebrewCalendar(tz), new IslamicCalendar(tz), new JapaneseCalendar(tz) };
    final String pattern = "GyMMMMdEEEEHHmmssVVVV";
    // FIXME The formatters commented out below are currently failing because of
    // the calendar calculation problem reported by #6691
    // The order of test formatters mus match the order of calendars above.
    final DateFormat[] formatters = { // calendar=gregorian
    DateFormat.getPatternInstance(pattern, new ULocale("en_US")), // calendar=buddhist
    DateFormat.getPatternInstance(pattern, new ULocale("th_TH")), DateFormat.getPatternInstance(pattern, new ULocale("he_IL@calendar=hebrew")) // DateFormat.getPatternInstance(pattern, new ULocale("ar_EG@calendar=islamic")),
    // DateFormat.getPatternInstance(pattern, new ULocale("ja_JP@calendar=japanese")),
    };
    Date d = new Date();
    StringBuffer buf = new StringBuffer();
    FieldPosition fpos = new FieldPosition(0);
    ParsePosition ppos = new ParsePosition(0);
    for (int i = 0; i < formatters.length; i++) {
        buf.setLength(0);
        fpos.setBeginIndex(0);
        fpos.setEndIndex(0);
        calendars[i].setTime(d);
        // Normal case output - the given calendar matches the calendar
        // used by the formatter
        formatters[i].format(calendars[i], buf, fpos);
        String refStr = buf.toString();
        for (int j = 0; j < calendars.length; j++) {
            if (j == i) {
                continue;
            }
            buf.setLength(0);
            fpos.setBeginIndex(0);
            fpos.setEndIndex(0);
            calendars[j].setTime(d);
            // Even the different calendar type is specified,
            // we should get the same result.
            formatters[i].format(calendars[j], buf, fpos);
            if (!refStr.equals(buf.toString())) {
                errln("FAIL: Different format result with a different calendar for the same time -" + "\n Reference calendar type=" + calendars[i].getType() + "\n Another calendar type=" + calendars[j].getType() + "\n Expected result=" + refStr + "\n Actual result=" + buf.toString());
            }
        }
        calendars[i].setTimeZone(gmt);
        calendars[i].clear();
        ppos.setErrorIndex(-1);
        ppos.setIndex(0);
        // Normal case parse result - the given calendar matches the calendar
        // used by the formatter
        formatters[i].parse(refStr, calendars[i], ppos);
        for (int j = 0; j < calendars.length; j++) {
            if (j == i) {
                continue;
            }
            calendars[j].setTimeZone(gmt);
            calendars[j].clear();
            ppos.setErrorIndex(-1);
            ppos.setIndex(0);
            // Even the different calendar type is specified,
            // we should get the same time and time zone.
            formatters[i].parse(refStr, calendars[j], ppos);
            if (calendars[i].getTimeInMillis() != calendars[j].getTimeInMillis() || !calendars[i].getTimeZone().equals(calendars[j].getTimeZone())) {
                errln("FAIL: Different parse result with a different calendar for the same string -" + "\n Reference calendar type=" + calendars[i].getType() + "\n Another calendar type=" + calendars[j].getType() + "\n Date string=" + refStr + "\n Expected time=" + calendars[i].getTimeInMillis() + "\n Expected time zone=" + calendars[i].getTimeZone().getID() + "\n Actual time=" + calendars[j].getTimeInMillis() + "\n Actual time zone=" + calendars[j].getTimeZone().getID());
            }
        }
    }
}
Also used : ULocale(android.icu.util.ULocale) BuddhistCalendar(android.icu.util.BuddhistCalendar) HebrewCalendar(android.icu.util.HebrewCalendar) IslamicCalendar(android.icu.util.IslamicCalendar) ChineseCalendar(android.icu.util.ChineseCalendar) GregorianCalendar(android.icu.util.GregorianCalendar) Calendar(android.icu.util.Calendar) JapaneseCalendar(android.icu.util.JapaneseCalendar) GregorianCalendar(android.icu.util.GregorianCalendar) FieldPosition(java.text.FieldPosition) JapaneseCalendar(android.icu.util.JapaneseCalendar) Date(java.util.Date) HebrewCalendar(android.icu.util.HebrewCalendar) TimeZone(android.icu.util.TimeZone) BuddhistCalendar(android.icu.util.BuddhistCalendar) DateFormat(android.icu.text.DateFormat) ChineseDateFormat(android.icu.text.ChineseDateFormat) SimpleDateFormat(android.icu.text.SimpleDateFormat) IslamicCalendar(android.icu.util.IslamicCalendar) ParsePosition(java.text.ParsePosition) Test(org.junit.Test)

Example 10 with JapaneseCalendar

use of android.icu.util.JapaneseCalendar in project j2objc by google.

the class GlobalizationPreferencesTest method TestCalendar.

@Test
public void TestCalendar() {
    GlobalizationPreferences gp = new GlobalizationPreferences();
    // Set locale - pt_BR
    logln("Set locale - pt");
    gp.setLocale(new ULocale("pt"));
    Calendar cal = gp.getCalendar();
    String calType = cal.getType();
    if (!calType.equals("gregorian")) {
        errln("FAIL: Calendar type is " + calType + " Expected: gregorian");
    }
    // Set a list of locales
    logln("Set locales - en, en_JP, en_GB");
    ULocale[] locales = new ULocale[3];
    locales[0] = new ULocale("en");
    locales[1] = new ULocale("en_JP");
    locales[2] = new ULocale("en_GB");
    gp.setLocales(locales);
    cal = gp.getCalendar();
    ULocale calLocale = cal.getLocale(ULocale.VALID_LOCALE);
    if (!calLocale.equals(locales[2])) {
        errln("FAIL: Calendar locale is " + calLocale.toString() + " - Expected: en_GB");
    }
    // Set ecplicit calendar
    logln("Set Japanese calendar to this object");
    JapaneseCalendar jcal = new JapaneseCalendar();
    gp.setCalendar(jcal);
    cal = gp.getCalendar();
    calType = cal.getType();
    if (!calType.equals("japanese")) {
        errln("FAIL: Calendar type is " + calType + " Expected: japanese");
    }
    jcal.setFirstDayOfWeek(3);
    if (cal.getFirstDayOfWeek() == jcal.getFirstDayOfWeek()) {
        errln("FAIL: Calendar returned by getCalendar must be a safe copy");
    }
    cal.setFirstDayOfWeek(3);
    Calendar cal1 = gp.getCalendar();
    if (cal1.getFirstDayOfWeek() == cal.getFirstDayOfWeek()) {
        errln("FAIL: Calendar returned by getCalendar must be a safe copy");
    }
    // Freeze
    logln("Freeze this object");
    IslamicCalendar ical = new IslamicCalendar();
    boolean bFrozen = false;
    gp.freeze();
    try {
        gp.setCalendar(ical);
    } catch (UnsupportedOperationException uoe) {
        logln("setCalendar is blocked");
        bFrozen = true;
    }
    if (!bFrozen) {
        errln("FAIL: setCalendar must be blocked");
    }
    // Safe clone
    logln("cloneAsThawed");
    GlobalizationPreferences gp1 = (GlobalizationPreferences) gp.cloneAsThawed();
    cal = gp.getCalendar();
    calType = cal.getType();
    if (!calType.equals("japanese")) {
        errln("FAIL: Calendar type afte clone is " + calType + " Expected: japanese");
    }
    logln("Set islamic calendar");
    gp1.setCalendar(ical);
    cal = gp1.getCalendar();
    calType = cal.getType();
    if (!calType.equals("islamic-civil")) {
        // default constructed IslamicCalendar is islamic-civil
        errln("FAIL: Calendar type afte clone is " + calType + " Expected: islamic-civil");
    }
}
Also used : GlobalizationPreferences(android.icu.util.GlobalizationPreferences) ULocale(android.icu.util.ULocale) IslamicCalendar(android.icu.util.IslamicCalendar) GregorianCalendar(android.icu.util.GregorianCalendar) BuddhistCalendar(android.icu.util.BuddhistCalendar) Calendar(android.icu.util.Calendar) JapaneseCalendar(android.icu.util.JapaneseCalendar) JapaneseCalendar(android.icu.util.JapaneseCalendar) IslamicCalendar(android.icu.util.IslamicCalendar) Test(org.junit.Test)

Aggregations

JapaneseCalendar (android.icu.util.JapaneseCalendar)10 Test (org.junit.Test)10 SimpleDateFormat (android.icu.text.SimpleDateFormat)6 Calendar (android.icu.util.Calendar)6 ULocale (android.icu.util.ULocale)6 DateFormat (android.icu.text.DateFormat)5 GregorianCalendar (android.icu.util.GregorianCalendar)5 Date (java.util.Date)5 IslamicCalendar (android.icu.util.IslamicCalendar)4 BuddhistCalendar (android.icu.util.BuddhistCalendar)3 ParseException (java.text.ParseException)3 GlobalizationPreferences (android.icu.util.GlobalizationPreferences)2 TimeZone (android.icu.util.TimeZone)2 ParsePosition (java.text.ParsePosition)2 ChineseDateFormat (android.icu.text.ChineseDateFormat)1 ChineseCalendar (android.icu.util.ChineseCalendar)1 HebrewCalendar (android.icu.util.HebrewCalendar)1 FieldPosition (java.text.FieldPosition)1 ArrayList (java.util.ArrayList)1 Locale (java.util.Locale)1