Search in sources :

Example 11 with SimpleTimeZone

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

the class TimeZoneTest method TestZoneMeta.

@Test
public void TestZoneMeta() {
    java.util.TimeZone save = java.util.TimeZone.getDefault();
    java.util.TimeZone newZone = java.util.TimeZone.getTimeZone("GMT-08:00");
    android.icu.util.TimeZone.setDefault(null);
    java.util.TimeZone.setDefault(newZone);
    SimpleTimeZone zone = new SimpleTimeZone(0, "GMT");
    android.icu.util.TimeZone defaultZone = android.icu.util.TimeZone.getDefault();
    if (defaultZone == null) {
        errln("TimeZone.getDefault() failed for GMT-08:00");
    }
    if (zone == null) {
        errln("SimpleTimeZone(0, GMT-08:00) failed for GMT-08:00");
    }
    // reset
    java.util.TimeZone.setDefault(save);
}
Also used : SimpleTimeZone(android.icu.util.SimpleTimeZone) TimeZone(android.icu.util.TimeZone) Test(org.junit.Test)

Example 12 with SimpleTimeZone

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

the class TimeZoneTest method TestDisplayName.

/**
 * Test the basic functionality of the getDisplayName() API.
 *
 * Bug 4112869
 * Bug 4028006
 *
 * See also API change request A41.
 *
 * 4/21/98 - make smarter, so the test works if the ext resources
 * are present or not.
 */
@Test
public void TestDisplayName() {
    TimeZone zone = TimeZone.getTimeZone("PST");
    String name = zone.getDisplayName(Locale.ENGLISH);
    logln("PST->" + name);
    // dlf - we now (3.4.1) return generic time
    if (!name.equals("Pacific Time"))
        errln("Fail: Expected \"Pacific Time\", got " + name + " for " + zone);
    // *****************************************************************
    // THE FOLLOWING LINES MUST BE UPDATED IF THE LOCALE DATA CHANGES
    // THE FOLLOWING LINES MUST BE UPDATED IF THE LOCALE DATA CHANGES
    // THE FOLLOWING LINES MUST BE UPDATED IF THE LOCALE DATA CHANGES
    // *****************************************************************
    // Test to allow the user to choose to get all the forms
    // (z, zzzz, Z, ZZZZ, v, vvvv)
    // todo: check to see whether we can test for all of pst, pdt, pt
    Object[] DATA = { // z and zzzz
    Boolean.FALSE, new Integer(TimeZone.SHORT), "PST", Boolean.TRUE, new Integer(TimeZone.SHORT), "PDT", Boolean.FALSE, new Integer(TimeZone.LONG), "Pacific Standard Time", Boolean.TRUE, new Integer(TimeZone.LONG), "Pacific Daylight Time", // v and vvvv
    Boolean.FALSE, new Integer(TimeZone.SHORT_GENERIC), "PT", Boolean.TRUE, new Integer(TimeZone.SHORT_GENERIC), "PT", Boolean.FALSE, new Integer(TimeZone.LONG_GENERIC), "Pacific Time", Boolean.TRUE, new Integer(TimeZone.LONG_GENERIC), "Pacific Time", // z and ZZZZ
    Boolean.FALSE, new Integer(TimeZone.SHORT_GMT), "-0800", Boolean.TRUE, new Integer(TimeZone.SHORT_GMT), "-0700", Boolean.FALSE, new Integer(TimeZone.LONG_GMT), "GMT-08:00", Boolean.TRUE, new Integer(TimeZone.LONG_GMT), "GMT-07:00", // V and VVVV
    Boolean.FALSE, new Integer(TimeZone.SHORT_COMMONLY_USED), "PST", Boolean.TRUE, new Integer(TimeZone.SHORT_COMMONLY_USED), "PDT", Boolean.FALSE, new Integer(TimeZone.GENERIC_LOCATION), "Los Angeles Time", Boolean.TRUE, new Integer(TimeZone.GENERIC_LOCATION), "Los Angeles Time" };
    for (int i = 0; i < DATA.length; i += 3) {
        name = zone.getDisplayName(((Boolean) DATA[i]).booleanValue(), ((Integer) DATA[i + 1]).intValue(), Locale.ENGLISH);
        if (!name.equals(DATA[i + 2]))
            errln("Fail: Expected " + DATA[i + 2] + "; got " + name);
    }
    // Make sure that we don't display the DST name by constructing a fake
    // PST zone that has DST all year long.
    // dlf - this test is no longer relevant, we display generic time now
    // so the behavior of the timezone doesn't matter
    SimpleTimeZone zone2 = new SimpleTimeZone(0, "PST");
    zone2.setStartRule(Calendar.JANUARY, 1, 0);
    zone2.setEndRule(Calendar.DECEMBER, 31, 86399999);
    logln("Modified PST inDaylightTime->" + zone2.inDaylightTime(new Date()));
    name = zone2.getDisplayName(Locale.ENGLISH);
    logln("Modified PST->" + name);
    if (!name.equals("Pacific Time"))
        errln("Fail: Expected \"Pacific Time\"");
    // Make sure we get the default display format for Locales
    // with no display name data.
    Locale mt_MT = new Locale("mt", "MT");
    name = zone.getDisplayName(mt_MT);
    // *****************************************************************
    // THE FOLLOWING LINE MUST BE UPDATED IF THE LOCALE DATA CHANGES
    // THE FOLLOWING LINE MUST BE UPDATED IF THE LOCALE DATA CHANGES
    // THE FOLLOWING LINE MUST BE UPDATED IF THE LOCALE DATA CHANGES
    // *****************************************************************
    logln("PST(mt_MT)->" + name);
    // Now be smart -- check to see if zh resource is even present.
    // If not, we expect the en fallback behavior.
    // in icu4j 2.1 we know we have the zh_CN locale data, though it's incomplete
    // /"DateFormatZoneData",
    UResourceBundle enRB = UResourceBundle.getBundleInstance(ICUData.ICU_BASE_NAME, Locale.ENGLISH);
    UResourceBundle mtRB = UResourceBundle.getBundleInstance(ICUData.ICU_BASE_NAME, mt_MT);
    boolean noZH = enRB == mtRB;
    if (noZH) {
        logln("Warning: Not testing the mt_MT behavior because resource is absent");
        if (!name.equals("Pacific Standard Time"))
            errln("Fail: Expected Pacific Standard Time for PST in mt_MT but got ");
    } else // - we now (3.4.1) have localizations for this zone, so change test string
    if (!name.equals("\u0126in ta\u2019 Los Angeles") && !name.equals("GMT-08:00") && !name.equals("GMT-8:00") && !name.equals("GMT-0800") && !name.equals("GMT-800")) {
        errln("Fail: got '" + name + "', expected GMT-08:00 or something similar\n" + "************************************************************\n" + "THE ABOVE FAILURE MAY JUST MEAN THE LOCALE DATA HAS CHANGED\n" + "************************************************************");
    }
    // Now try a non-existent zone
    zone2 = new SimpleTimeZone(90 * 60 * 1000, "xyzzy");
    name = zone2.getDisplayName(Locale.ENGLISH);
    logln("GMT+90min->" + name);
    if (!name.equals("GMT+01:30") && !name.equals("GMT+1:30") && !name.equals("GMT+0130") && !name.equals("GMT+130"))
        errln("Fail: Expected GMT+01:30 or something similar");
    // cover getDisplayName() - null arg
    ULocale save = ULocale.getDefault();
    ULocale.setDefault(ULocale.US);
    name = zone2.getDisplayName();
    logln("GMT+90min->" + name + "for default display locale");
    if (!name.equals("GMT+01:30") && !name.equals("GMT+1:30") && !name.equals("GMT+0130") && !name.equals("GMT+130"))
        errln("Fail: Expected GMT+01:30 or something similar");
    ULocale.setDefault(save);
}
Also used : Locale(java.util.Locale) ULocale(android.icu.util.ULocale) UResourceBundle(android.icu.util.UResourceBundle) ULocale(android.icu.util.ULocale) Date(java.util.Date) SimpleTimeZone(android.icu.util.SimpleTimeZone) TimeZone(android.icu.util.TimeZone) NativeTimeZone(com.google.j2objc.util.NativeTimeZone) BasicTimeZone(android.icu.util.BasicTimeZone) JavaTimeZone(android.icu.impl.JavaTimeZone) VTimeZone(android.icu.util.VTimeZone) RuleBasedTimeZone(android.icu.util.RuleBasedTimeZone) SimpleTimeZone(android.icu.util.SimpleTimeZone) Test(org.junit.Test)

Example 13 with SimpleTimeZone

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

the class TimeZoneTest method TestDSTSavings.

/**
 * Bug 4107276
 */
@Test
public void TestDSTSavings() {
    // It might be better to find a way to integrate this test into the main TimeZone
    // tests above, but I don't have time to figure out how to do this (or if it's
    // even really a good idea).  Let's consider that a future.  --rtg 1/27/98
    SimpleTimeZone tz = new SimpleTimeZone(-5 * millisPerHour, "dstSavingsTest", Calendar.MARCH, 1, 0, 0, Calendar.SEPTEMBER, 1, 0, 0, (int) (0.5 * millisPerHour));
    if (tz.getRawOffset() != -5 * millisPerHour)
        errln("Got back a raw offset of " + (tz.getRawOffset() / millisPerHour) + " hours instead of -5 hours.");
    if (!tz.useDaylightTime())
        errln("Test time zone should use DST but claims it doesn't.");
    if (tz.getDSTSavings() != 0.5 * millisPerHour)
        errln("Set DST offset to 0.5 hour, but got back " + (tz.getDSTSavings() / millisPerHour) + " hours instead.");
    int offset = tz.getOffset(GregorianCalendar.AD, 1998, Calendar.JANUARY, 1, Calendar.THURSDAY, 10 * millisPerHour);
    if (offset != -5 * millisPerHour)
        errln("The offset for 10 AM, 1/1/98 should have been -5 hours, but we got " + (offset / millisPerHour) + " hours.");
    offset = tz.getOffset(GregorianCalendar.AD, 1998, Calendar.JUNE, 1, Calendar.MONDAY, 10 * millisPerHour);
    if (offset != -4.5 * millisPerHour)
        errln("The offset for 10 AM, 6/1/98 should have been -4.5 hours, but we got " + (offset / millisPerHour) + " hours.");
    tz.setDSTSavings(millisPerHour);
    offset = tz.getOffset(GregorianCalendar.AD, 1998, Calendar.JANUARY, 1, Calendar.THURSDAY, 10 * millisPerHour);
    if (offset != -5 * millisPerHour)
        errln("The offset for 10 AM, 1/1/98 should have been -5 hours, but we got " + (offset / millisPerHour) + " hours.");
    offset = tz.getOffset(GregorianCalendar.AD, 1998, Calendar.JUNE, 1, Calendar.MONDAY, 10 * millisPerHour);
    if (offset != -4 * millisPerHour)
        errln("The offset for 10 AM, 6/1/98 (with a 1-hour DST offset) should have been -4 hours, but we got " + (offset / millisPerHour) + " hours.");
}
Also used : SimpleTimeZone(android.icu.util.SimpleTimeZone) Test(org.junit.Test)

Example 14 with SimpleTimeZone

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

the class TimeZoneOffsetLocalTest method TestGetOffsetAroundTransition.

/*
     * Testing getOffset APIs around rule transition by local standard/wall time.
     */
@Test
public void TestGetOffsetAroundTransition() {
    final int HOUR = 60 * 60 * 1000;
    final int MINUTE = 60 * 1000;
    int[][] DATES = { { 2006, Calendar.APRIL, 2, 1, 30, 1 * HOUR + 30 * MINUTE }, { 2006, Calendar.APRIL, 2, 2, 00, 2 * HOUR }, { 2006, Calendar.APRIL, 2, 2, 30, 2 * HOUR + 30 * MINUTE }, { 2006, Calendar.APRIL, 2, 3, 00, 3 * HOUR }, { 2006, Calendar.APRIL, 2, 3, 30, 3 * HOUR + 30 * MINUTE }, { 2006, Calendar.OCTOBER, 29, 0, 30, 0 * HOUR + 30 * MINUTE }, { 2006, Calendar.OCTOBER, 29, 1, 00, 1 * HOUR }, { 2006, Calendar.OCTOBER, 29, 1, 30, 1 * HOUR + 30 * MINUTE }, { 2006, Calendar.OCTOBER, 29, 2, 00, 2 * HOUR }, { 2006, Calendar.OCTOBER, 29, 2, 30, 2 * HOUR + 30 * MINUTE } };
    // Expected offsets by getOffset(int era, int year, int month, int day, int dayOfWeek, int milliseconds)
    int[] OFFSETS1 = { // April 2, 2006
    -8 * HOUR, -7 * HOUR, -7 * HOUR, -7 * HOUR, -7 * HOUR, // October 29, 2006
    -7 * HOUR, -8 * HOUR, -8 * HOUR, -8 * HOUR, -8 * HOUR };
    // Expected offsets by getOffset(long time, boolean local, int[] offsets) with local = true
    // or getOffsetFromLocal(long time, int nonExistingTimeOpt, int duplicatedTimeOpt, int[] offsets)
    // with nonExistingTimeOpt = LOCAL_STD/duplicatedTimeOpt = LOCAL_STD
    int[][] OFFSETS2 = { // April 2, 2006
    { -8 * HOUR, 0 }, { -8 * HOUR, 0 }, { -8 * HOUR, 0 }, { -8 * HOUR, 1 * HOUR }, { -8 * HOUR, 1 * HOUR }, // Oct 29, 2006
    { -8 * HOUR, 1 * HOUR }, { -8 * HOUR, 0 }, { -8 * HOUR, 0 }, { -8 * HOUR, 0 }, { -8 * HOUR, 0 } };
    // Expected offsets by getOffsetFromLocal(long time, int nonExistingTimeOpt, int duplicatedTimeOpt, int[] offsets)
    // with nonExistingTimeOpt = LOCAL_DST/duplicatedTimeOpt = LOCAL_DST
    int[][] OFFSETS3 = { // April 2, 2006
    { -8 * HOUR, 0 }, { -8 * HOUR, 1 * HOUR }, { -8 * HOUR, 1 * HOUR }, { -8 * HOUR, 1 * HOUR }, { -8 * HOUR, 1 * HOUR }, // October 29, 2006
    { -8 * HOUR, 1 * HOUR }, { -8 * HOUR, 1 * HOUR }, { -8 * HOUR, 1 * HOUR }, { -8 * HOUR, 0 }, { -8 * HOUR, 0 } };
    int[] offsets = new int[2];
    TimeZone utc = TimeZone.getTimeZone("UTC");
    Calendar cal = Calendar.getInstance(utc);
    cal.clear();
    // Set up TimeZone objects - OlsonTimeZone, SimpleTimeZone and RuleBasedTimeZone
    BasicTimeZone[] TESTZONES = new BasicTimeZone[3];
    TESTZONES[0] = (BasicTimeZone) TimeZone.getTimeZone("America/Los_Angeles", TimeZone.TIMEZONE_ICU);
    TESTZONES[1] = new SimpleTimeZone(-8 * HOUR, "Simple Pacific Time", Calendar.APRIL, 1, Calendar.SUNDAY, 2 * HOUR, Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * HOUR);
    InitialTimeZoneRule ir = new InitialTimeZoneRule(// Initial time Name
    "Pacific Standard Time", // Raw offset
    -8 * HOUR, // DST saving amount
    0 * HOUR);
    RuleBasedTimeZone rbPT = new RuleBasedTimeZone("Rule based Pacific Time", ir);
    DateTimeRule dtr;
    AnnualTimeZoneRule atzr;
    final int STARTYEAR = 2000;
    dtr = new DateTimeRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * HOUR, // 1st Sunday in April, at 2AM wall time
    DateTimeRule.WALL_TIME);
    atzr = new AnnualTimeZoneRule("Pacific Daylight Time", -8 * HOUR, /* rawOffset */
    1 * HOUR, /* dstSavings */
    dtr, STARTYEAR, AnnualTimeZoneRule.MAX_YEAR);
    rbPT.addTransitionRule(atzr);
    dtr = new DateTimeRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * HOUR, // last Sunday in October, at 2AM wall time
    DateTimeRule.WALL_TIME);
    atzr = new AnnualTimeZoneRule("Pacific Standard Time", -8 * HOUR, /* rawOffset */
    0, /* dstSavings */
    dtr, STARTYEAR, AnnualTimeZoneRule.MAX_YEAR);
    rbPT.addTransitionRule(atzr);
    TESTZONES[2] = rbPT;
    // Calculate millis
    long[] MILLIS = new long[DATES.length];
    for (int i = 0; i < DATES.length; i++) {
        cal.clear();
        cal.set(DATES[i][0], DATES[i][1], DATES[i][2], DATES[i][3], DATES[i][4]);
        MILLIS[i] = cal.getTimeInMillis();
    }
    DateFormat df = DateFormat.getInstance();
    df.setTimeZone(utc);
    // Test getOffset(int era, int year, int month, int day, int dayOfWeek, int millis)
    for (int i = 0; i < TESTZONES.length; i++) {
        for (int d = 0; d < DATES.length; d++) {
            int offset = TESTZONES[i].getOffset(GregorianCalendar.AD, DATES[d][0], DATES[d][1], DATES[d][2], Calendar.SUNDAY, DATES[d][5]);
            if (offset != OFFSETS1[d]) {
                errln("Bad offset returned by " + TESTZONES[i].getID() + " at " + df.format(new Date(MILLIS[d])) + "(standard) - Got: " + offset + " Expected: " + OFFSETS1[d]);
            }
        }
    }
    // Test getOffset(long time, boolean local, int[] offsets) with local=true
    for (int i = 0; i < TESTZONES.length; i++) {
        for (int m = 0; m < MILLIS.length; m++) {
            TESTZONES[i].getOffset(MILLIS[m], true, offsets);
            if (offsets[0] != OFFSETS2[m][0] || offsets[1] != OFFSETS2[m][1]) {
                errln("Bad offset returned by " + TESTZONES[i].getID() + " at " + df.format(new Date(MILLIS[m])) + "(wall) - Got: " + offsets[0] + "/" + offsets[1] + " Expected: " + OFFSETS2[m][0] + "/" + OFFSETS2[m][1]);
            }
        }
    }
    // with nonExistingTimeOpt = LOCAL_STD/duplicatedTimeOpt = LOCAL_STD
    for (int i = 0; i < TESTZONES.length; i++) {
        for (int m = 0; m < MILLIS.length; m++) {
            TESTZONES[i].getOffsetFromLocal(MILLIS[m], BasicTimeZone.LOCAL_STD, BasicTimeZone.LOCAL_STD, offsets);
            if (offsets[0] != OFFSETS2[m][0] || offsets[1] != OFFSETS2[m][1]) {
                errln("Bad offset returned by " + TESTZONES[i].getID() + " at " + df.format(new Date(MILLIS[m])) + "(wall/STD/STD) - Got: " + offsets[0] + "/" + offsets[1] + " Expected: " + OFFSETS2[m][0] + "/" + OFFSETS2[m][1]);
            }
        }
    }
    // with nonExistingTimeOpt = LOCAL_DST/duplicatedTimeOpt = LOCAL_DST
    for (int i = 0; i < TESTZONES.length; i++) {
        for (int m = 0; m < MILLIS.length; m++) {
            TESTZONES[i].getOffsetFromLocal(MILLIS[m], BasicTimeZone.LOCAL_DST, BasicTimeZone.LOCAL_DST, offsets);
            if (offsets[0] != OFFSETS3[m][0] || offsets[1] != OFFSETS3[m][1]) {
                errln("Bad offset returned by " + TESTZONES[i].getID() + " at " + df.format(new Date(MILLIS[m])) + "(wall/DST/DST) - Got: " + offsets[0] + "/" + offsets[1] + " Expected: " + OFFSETS3[m][0] + "/" + OFFSETS3[m][1]);
            }
        }
    }
    // with nonExistingTimeOpt = LOCAL_FORMER/duplicatedTimeOpt = LOCAL_LATTER
    for (int i = 0; i < TESTZONES.length; i++) {
        for (int m = 0; m < MILLIS.length; m++) {
            TESTZONES[i].getOffsetFromLocal(MILLIS[m], BasicTimeZone.LOCAL_FORMER, BasicTimeZone.LOCAL_LATTER, offsets);
            if (offsets[0] != OFFSETS2[m][0] || offsets[1] != OFFSETS2[m][1]) {
                errln("Bad offset returned by " + TESTZONES[i].getID() + " at " + df.format(new Date(MILLIS[m])) + "(wall/FORMER/LATTER) - Got: " + offsets[0] + "/" + offsets[1] + " Expected: " + OFFSETS2[m][0] + "/" + OFFSETS2[m][1]);
            }
        }
    }
    // with nonExistingTimeOpt = LOCAL_LATTER/duplicatedTimeOpt = LOCAL_FORMER
    for (int i = 0; i < TESTZONES.length; i++) {
        for (int m = 0; m < MILLIS.length; m++) {
            TESTZONES[i].getOffsetFromLocal(MILLIS[m], BasicTimeZone.LOCAL_LATTER, BasicTimeZone.LOCAL_FORMER, offsets);
            if (offsets[0] != OFFSETS3[m][0] || offsets[1] != OFFSETS3[m][1]) {
                errln("Bad offset returned by " + TESTZONES[i].getID() + " at " + df.format(new Date(MILLIS[m])) + "(wall/LATTER/FORMER) - Got: " + offsets[0] + "/" + offsets[1] + " Expected: " + OFFSETS3[m][0] + "/" + OFFSETS3[m][1]);
            }
        }
    }
}
Also used : InitialTimeZoneRule(android.icu.util.InitialTimeZoneRule) AnnualTimeZoneRule(android.icu.util.AnnualTimeZoneRule) GregorianCalendar(android.icu.util.GregorianCalendar) Calendar(android.icu.util.Calendar) RuleBasedTimeZone(android.icu.util.RuleBasedTimeZone) Date(java.util.Date) DateTimeRule(android.icu.util.DateTimeRule) SimpleTimeZone(android.icu.util.SimpleTimeZone) TimeZone(android.icu.util.TimeZone) BasicTimeZone(android.icu.util.BasicTimeZone) RuleBasedTimeZone(android.icu.util.RuleBasedTimeZone) BasicTimeZone(android.icu.util.BasicTimeZone) SimpleTimeZone(android.icu.util.SimpleTimeZone) DateFormat(android.icu.text.DateFormat) Test(org.junit.Test)

Example 15 with SimpleTimeZone

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

the class TimeZoneRegressionTest method Test4159922.

/**
 * TimeZone constructors allow null IDs.
 */
@Test
public void Test4159922() {
    TimeZone z = null;
    // allow null.
    try {
        z = TimeZone.getTimeZone(null);
        errln("FAIL: Null allowed in getTimeZone");
    } catch (NullPointerException e) {
        System.out.print("");
    }
    z = TimeZone.getTimeZone("GMT");
    try {
        // {dlf} requiring cast for disambiguation is ok for compatibility since null
        // is not a valid argument to this API
        z.getDisplayName(false, TimeZone.SHORT, (ULocale) null);
        errln("FAIL: Null allowed in getDisplayName(3)");
    } catch (NullPointerException e) {
        System.out.print("");
    }
    try {
        // {dlf} see above
        z.getDisplayName((ULocale) null);
        errln("FAIL: Null allowed in getDisplayName(1)");
    } catch (NullPointerException e) {
        System.out.print("");
    }
    try {
        if (z.hasSameRules(null)) {
            errln("FAIL: hasSameRules returned true");
        }
    } catch (NullPointerException e) {
        errln("FAIL: Null NOT allowed in hasSameRules");
    }
    try {
        z.inDaylightTime(null);
        errln("FAIL: Null allowed in inDaylightTime");
    } catch (NullPointerException e) {
        System.out.print("");
    }
    try {
        z.setID(null);
        errln("FAIL: Null allowed in setID");
    } catch (NullPointerException e) {
        System.out.print("");
    }
    TimeZone save = TimeZone.getDefault();
    try {
        TimeZone.setDefault(null);
    } catch (NullPointerException e) {
        errln("FAIL: Null NOT allowed in setDefault");
    } finally {
        TimeZone.setDefault(save);
    }
    // SimpleTimeZone API
    SimpleTimeZone s = null;
    try {
        s = new SimpleTimeZone(0, null);
        errln("FAIL: Null allowed in SimpleTimeZone(2)");
    } catch (NullPointerException e) {
        System.out.print("");
    }
    try {
        s = new SimpleTimeZone(0, null, 0, 1, 0, 0, 0, 1, 0, 0);
        errln("FAIL: Null allowed in SimpleTimeZone(10)");
    } catch (NullPointerException e) {
        System.out.print("");
    }
    try {
        s = new SimpleTimeZone(0, null, 0, 1, 0, 0, 0, 1, 0, 0, 1000);
        errln("FAIL: Null allowed in SimpleTimeZone(11)");
    } catch (NullPointerException e) {
        System.out.print("");
    }
    if (s != null) {
        errln("FAIL: Did not get the expected Exception");
    }
}
Also used : SimpleTimeZone(android.icu.util.SimpleTimeZone) TimeZone(android.icu.util.TimeZone) SimpleTimeZone(android.icu.util.SimpleTimeZone) Test(org.junit.Test)

Aggregations

SimpleTimeZone (android.icu.util.SimpleTimeZone)39 Test (org.junit.Test)35 TimeZone (android.icu.util.TimeZone)17 Date (java.util.Date)15 GregorianCalendar (android.icu.util.GregorianCalendar)14 BasicTimeZone (android.icu.util.BasicTimeZone)10 Calendar (android.icu.util.Calendar)9 RuleBasedTimeZone (android.icu.util.RuleBasedTimeZone)9 JavaTimeZone (android.icu.impl.JavaTimeZone)7 VTimeZone (android.icu.util.VTimeZone)7 NativeTimeZone (com.google.j2objc.util.NativeTimeZone)7 SimpleDateFormat (android.icu.text.SimpleDateFormat)6 InitialTimeZoneRule (android.icu.util.InitialTimeZoneRule)5 CalendarAstronomer (android.icu.impl.CalendarAstronomer)4 AnnualTimeZoneRule (android.icu.util.AnnualTimeZoneRule)4 TimeArrayTimeZoneRule (android.icu.util.TimeArrayTimeZoneRule)4 DateFormat (android.icu.text.DateFormat)3 DateTimeRule (android.icu.util.DateTimeRule)3 TimeZoneTransition (android.icu.util.TimeZoneTransition)3 ULocale (android.icu.util.ULocale)3