Search in sources :

Example 11 with SimpleTimeZone

use of java.util.SimpleTimeZone in project robovm by robovm.

the class SimpleTimeZoneTest method test_setEndRuleIIIIZ.

/**
     * java.util.SimpleTimeZone#setEndRule(int, int, int, int, boolean)
     */
public void test_setEndRuleIIIIZ() {
    // Test for method void java.util.SimpleTimeZone.setEndRule(int, int,
    // int, int, boolean)
    SimpleTimeZone st = new SimpleTimeZone(1000, "Test_TZ");
    // Spec indicates that both end and start must be set or result is
    // undefined
    st.setStartRule(Calendar.NOVEMBER, 8, Calendar.SUNDAY, 1, false);
    st.setEndRule(Calendar.NOVEMBER, 15, Calendar.SUNDAY, 1, true);
    assertTrue("StartRule improperly set1", st.useDaylightTime());
    assertTrue("StartRule improperly set2", st.inDaylightTime((new GregorianCalendar(1999, Calendar.NOVEMBER, 7, 12, 0).getTime())));
    assertTrue("StartRule improperly set3", st.inDaylightTime((new GregorianCalendar(1999, Calendar.NOVEMBER, 20, 12, 0).getTime())));
    assertTrue("StartRule improperly set4", !(st.inDaylightTime(new GregorianCalendar(1999, Calendar.NOVEMBER, 6, 12, 0).getTime())));
    assertTrue("StartRule improperly set5", !(st.inDaylightTime(new GregorianCalendar(1999, Calendar.NOVEMBER, 21, 12, 0).getTime())));
    try {
        st.setEndRule(20, 15, Calendar.SUNDAY, 1, true);
        fail("IllegalArgumentException is not thrown.");
    } catch (IllegalArgumentException iae) {
    //expected
    }
    try {
        st.setEndRule(Calendar.NOVEMBER, 35, Calendar.SUNDAY, 1, true);
        fail("IllegalArgumentException is not thrown.");
    } catch (IllegalArgumentException iae) {
    //expected
    }
    try {
        st.setEndRule(Calendar.NOVEMBER, 15, 12, 1, true);
        fail("IllegalArgumentException is not thrown.");
    } catch (IllegalArgumentException iae) {
    //expected
    }
    try {
        st.setEndRule(Calendar.NOVEMBER, 15, Calendar.SUNDAY, -1, true);
        fail("IllegalArgumentException is not thrown.");
    } catch (IllegalArgumentException iae) {
    //expected
    }
}
Also used : SimpleTimeZone(java.util.SimpleTimeZone) GregorianCalendar(java.util.GregorianCalendar)

Example 12 with SimpleTimeZone

use of java.util.SimpleTimeZone in project robovm by robovm.

the class SimpleTimeZoneTest method test_hasSameRulesLjava_util_TimeZone.

/**
     * java.util.SimpleTimeZone#hasSameRules(java.util.TimeZone)
     */
public void test_hasSameRulesLjava_util_TimeZone() {
    // Test for method boolean
    // java.util.SimpleTimeZone.hasSameRules(java.util.TimeZone)
    SimpleTimeZone st = new SimpleTimeZone(1000, "TEST", Calendar.NOVEMBER, 1, Calendar.SUNDAY, 0, Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0);
    SimpleTimeZone sameAsSt = new SimpleTimeZone(1000, "REST", Calendar.NOVEMBER, 1, Calendar.SUNDAY, 0, Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0);
    SimpleTimeZone notSameAsSt = new SimpleTimeZone(1000, "PEST", Calendar.NOVEMBER, 2, Calendar.SUNDAY, 0, Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0);
    assertTrue("Time zones have same rules but return false", st.hasSameRules(sameAsSt));
    assertTrue("Time zones have different rules but return true", !st.hasSameRules(notSameAsSt));
}
Also used : SimpleTimeZone(java.util.SimpleTimeZone)

Example 13 with SimpleTimeZone

use of java.util.SimpleTimeZone in project robovm by robovm.

the class SimpleTimeZoneTest method test_ConstructorILjava_lang_StringIIIIIIII.

/**
     * java.util.SimpleTimeZone#SimpleTimeZone(int, java.lang.String,
     *        int, int, int, int, int, int, int, int)
     */
public void test_ConstructorILjava_lang_StringIIIIIIII() {
    // Test for method java.util.SimpleTimeZone(int, java.lang.String, int,
    // int, int, int, int, int, int, int)
    SimpleTimeZone st = new SimpleTimeZone(1000, "TEST", Calendar.NOVEMBER, 1, Calendar.SUNDAY, 0, Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0);
    assertTrue("Incorrect TZ constructed", st.inDaylightTime(new GregorianCalendar(1998, Calendar.NOVEMBER, 13).getTime()));
    assertTrue("Incorrect TZ constructed", !(st.inDaylightTime(new GregorianCalendar(1998, Calendar.OCTOBER, 13).getTime())));
    assertEquals("Incorrect TZ constructed", "TEST", st.getID());
    assertEquals("Incorrect TZ constructed", 1000, st.getRawOffset());
    assertTrue("Incorrect TZ constructed", st.useDaylightTime());
    try {
        new SimpleTimeZone(1000, "TEST", 12, 1, Calendar.SUNDAY, 0, Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    //expected
    }
    try {
        new SimpleTimeZone(1000, "TEST", Calendar.NOVEMBER, 10, Calendar.SUNDAY, 0, Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    //expected
    }
    try {
        new SimpleTimeZone(1000, "TEST", Calendar.NOVEMBER, 1, 10, 0, Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    //expected
    }
    try {
        new SimpleTimeZone(1000, "TEST", Calendar.DECEMBER, 1, Calendar.SUNDAY, 0, Calendar.NOVEMBER, -10, Calendar.SUNDAY, 0);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    //expected
    }
}
Also used : SimpleTimeZone(java.util.SimpleTimeZone) GregorianCalendar(java.util.GregorianCalendar)

Example 14 with SimpleTimeZone

use of java.util.SimpleTimeZone in project robovm by robovm.

the class SimpleTimeZoneTest method test_setStartYearI.

/**
     * java.util.SimpleTimeZone#setStartYear(int)
     */
public void test_setStartYearI() {
    // Test for method void java.util.SimpleTimeZone.setStartYear(int)
    SimpleTimeZone st = new SimpleTimeZone(1000, "Test_TZ");
    st.setStartRule(Calendar.NOVEMBER, 1, Calendar.SUNDAY, 0);
    st.setEndRule(Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0);
    st.setStartYear(1999);
    assertTrue("set year improperly set1", !(st.inDaylightTime(new GregorianCalendar(1999, Calendar.JULY, 12).getTime())));
    assertTrue("set year improperly set2", !(st.inDaylightTime(new GregorianCalendar(1998, Calendar.OCTOBER, 13).getTime())));
    assertTrue("set year improperly set3", (st.inDaylightTime(new GregorianCalendar(1999, Calendar.NOVEMBER, 13).getTime())));
}
Also used : SimpleTimeZone(java.util.SimpleTimeZone) GregorianCalendar(java.util.GregorianCalendar)

Example 15 with SimpleTimeZone

use of java.util.SimpleTimeZone in project robovm by robovm.

the class SimpleTimeZoneTest method test_setStartRuleIIIIZ.

/**
     * java.util.SimpleTimeZone#setStartRule(int, int, int, int, boolean)
     */
public void test_setStartRuleIIIIZ() {
    TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
    // Test for method void java.util.SimpleTimeZone.setStartRule(int, int,
    // int, int, boolean)
    SimpleTimeZone st = new SimpleTimeZone(TimeZone.getTimeZone("EST").getRawOffset(), "EST");
    // Spec indicates that both end and start must be set or result is
    // undefined
    st.setStartRule(Calendar.NOVEMBER, 1, Calendar.SUNDAY, 1, true);
    st.setEndRule(Calendar.NOVEMBER, 15, Calendar.SUNDAY, 1, false);
    assertTrue("StartRule improperly set1", st.useDaylightTime());
    assertTrue("StartRule improperly set2", st.inDaylightTime((new GregorianCalendar(1999, Calendar.NOVEMBER, 7, 12, 0).getTime())));
    assertTrue("StartRule improperly set3", st.inDaylightTime((new GregorianCalendar(1999, Calendar.NOVEMBER, 13, 12, 0).getTime())));
    assertTrue("StartRule improperly set4", !(st.inDaylightTime(new GregorianCalendar(1999, Calendar.NOVEMBER, 6, 12, 0).getTime())));
    assertTrue("StartRule improperly set5", !(st.inDaylightTime(new GregorianCalendar(1999, Calendar.NOVEMBER, 14, 12, 0).getTime())));
    try {
        st.setStartRule(20, 15, Calendar.SUNDAY, 1, true);
        fail("IllegalArgumentException is not thrown.");
    } catch (IllegalArgumentException iae) {
    //expected
    }
    try {
        st.setStartRule(Calendar.NOVEMBER, 35, Calendar.SUNDAY, 1, true);
        fail("IllegalArgumentException is not thrown.");
    } catch (IllegalArgumentException iae) {
    //expected
    }
    try {
        st.setStartRule(Calendar.NOVEMBER, 15, 12, 1, true);
        fail("IllegalArgumentException is not thrown.");
    } catch (IllegalArgumentException iae) {
    //expected
    }
    try {
        st.setStartRule(Calendar.NOVEMBER, 15, Calendar.SUNDAY, -1, true);
        fail("IllegalArgumentException is not thrown.");
    } catch (IllegalArgumentException iae) {
    //expected
    }
}
Also used : SimpleTimeZone(java.util.SimpleTimeZone) GregorianCalendar(java.util.GregorianCalendar)

Aggregations

SimpleTimeZone (java.util.SimpleTimeZone)163 TimeZone (java.util.TimeZone)53 SimpleDateFormat (java.text.SimpleDateFormat)47 GregorianCalendar (java.util.GregorianCalendar)43 Date (java.util.Date)38 Calendar (java.util.Calendar)19 Test (org.junit.Test)16 DateFormat (java.text.DateFormat)8 File (java.io.File)5 NativeTimeZoneTest.isNativeTimeZone (com.google.j2objc.util.NativeTimeZoneTest.isNativeTimeZone)4 IOException (java.io.IOException)4 BasicDBObject (com.mongodb.BasicDBObject)3 InvalidObjectException (java.io.InvalidObjectException)3 Timestamp (java.sql.Timestamp)3 ParsePosition (java.text.ParsePosition)3 COSString (org.apache.pdfbox.cos.COSString)3 Support_TimeZone (tests.support.Support_TimeZone)3 DBRef (com.mongodb.DBRef)2 MessageFormat (java.text.MessageFormat)2 ParseException (java.text.ParseException)2