Search in sources :

Example 81 with SimpleTimeZone

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

the class SimpleTimeZoneTest method test_useDaylightTime.

/**
     * java.util.SimpleTimeZone#useDaylightTime()
     */
public void test_useDaylightTime() {
    // Test for method boolean java.util.SimpleTimeZone.useDaylightTime()
    SimpleTimeZone st = new SimpleTimeZone(1000, "Test_TZ");
    assertTrue("useDaylightTime returned incorrect value", !st.useDaylightTime());
    // Spec indicates that both end and start must be set or result is
    // undefined
    st.setStartRule(Calendar.NOVEMBER, 1, Calendar.SUNDAY, 0);
    st.setEndRule(Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0);
    assertTrue("useDaylightTime returned incorrect value", st.useDaylightTime());
}
Also used : SimpleTimeZone(java.util.SimpleTimeZone)

Example 82 with SimpleTimeZone

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

the class SimpleTimeZoneTest method test_setDSTSavingsI.

/**
     * java.util.SimpleTimeZone#setDSTSavings(int)
     */
public void test_setDSTSavingsI() {
    // Test for method void java.util.SimpleTimeZone.setDSTSavings(int)
    SimpleTimeZone st = new SimpleTimeZone(1000, "Test_TZ");
    st.setStartRule(0, 1, 1, 1);
    st.setEndRule(11, 1, 1, 1);
    st.setDSTSavings(1);
    assertEquals(1, st.getDSTSavings());
    try {
        st.setDSTSavings(0);
        fail();
    } catch (IllegalArgumentException expected) {
    }
    try {
        st.setDSTSavings(-1);
        fail();
    } catch (IllegalArgumentException expected) {
    }
}
Also used : SimpleTimeZone(java.util.SimpleTimeZone)

Example 83 with SimpleTimeZone

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

the class SimpleTimeZoneTest method test_setStartRuleIIII.

/**
     * java.util.SimpleTimeZone#setStartRule(int, int, int, int)
     */
public void test_setStartRuleIIII() {
    // Test for method void java.util.SimpleTimeZone.setStartRule(int, int,
    // int, int)
    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, 1, Calendar.SUNDAY, 0);
    st.setEndRule(Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0);
    assertTrue("StartRule improperly set1", st.useDaylightTime());
    assertTrue("StartRule improperly set2", st.inDaylightTime((new GregorianCalendar(1998, Calendar.NOVEMBER, 13).getTime())));
    assertTrue("StartRule improperly set3", !(st.inDaylightTime(new GregorianCalendar(1998, Calendar.OCTOBER, 13).getTime())));
    try {
        st.setStartRule(12, -1, Calendar.SUNDAY, 0);
        fail("IllegalArgumentException is not thrown.");
    } catch (IllegalArgumentException iae) {
    //expected
    }
    try {
        st.setStartRule(Calendar.NOVEMBER, 10, Calendar.SUNDAY, 0);
        fail("IllegalArgumentException is not thrown.");
    } catch (IllegalArgumentException iae) {
    //expected
    }
    try {
        st.setStartRule(Calendar.NOVEMBER, -1, 8, 0);
        fail("IllegalArgumentException is not thrown.");
    } catch (IllegalArgumentException iae) {
    //expected
    }
    try {
        st.setStartRule(Calendar.NOVEMBER, -1, Calendar.SUNDAY, -10);
        fail("IllegalArgumentException is not thrown.");
    } catch (IllegalArgumentException iae) {
    //expected
    }
}
Also used : SimpleTimeZone(java.util.SimpleTimeZone) GregorianCalendar(java.util.GregorianCalendar)

Example 84 with SimpleTimeZone

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

the class SimpleTimeZoneTest method test_clone.

/**
     * java.util.SimpleTimeZone#clone()
     */
public void test_clone() {
    // Test for method java.lang.Object java.util.SimpleTimeZone.clone()
    SimpleTimeZone st1 = new SimpleTimeZone(1000, "TEST", Calendar.NOVEMBER, 1, Calendar.SUNDAY, 0, Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0);
    SimpleTimeZone stA = new SimpleTimeZone(1, "Gah");
    assertTrue("Clone resulted in same reference", st1.clone() != st1);
    assertTrue("Clone resulted in unequal object", ((SimpleTimeZone) st1.clone()).equals(st1));
    assertTrue("Clone resulted in same reference", stA.clone() != stA);
    assertTrue("Clone resulted in unequal object", ((SimpleTimeZone) stA.clone()).equals(stA));
}
Also used : SimpleTimeZone(java.util.SimpleTimeZone)

Example 85 with SimpleTimeZone

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

the class SimpleTimeZoneTest method test_ConstructorILjava_lang_StringIIIIIIIII.

/**
     * java.util.SimpleTimeZone#SimpleTimeZone(int, java.lang.String,
     *        int, int, int, int, int, int, int, int, int)
     */
public void test_ConstructorILjava_lang_StringIIIIIIIII() {
    // Test for method java.util.SimpleTimeZone(int, java.lang.String, int,
    // 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, 1000 * 60 * 60);
    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());
    assertTrue("Incorrect TZ constructed", st.getDSTSavings() == 1000 * 60 * 60);
    try {
        new SimpleTimeZone(1000, "TEST", 12, 1, Calendar.SUNDAY, 0, Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0, 1000 * 60 * 60);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    //expected
    }
    try {
        new SimpleTimeZone(1000, "TEST", Calendar.NOVEMBER, 10, Calendar.SUNDAY, 0, Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0, 1000 * 60 * 60);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    //expected
    }
    try {
        new SimpleTimeZone(1000, "TEST", Calendar.NOVEMBER, 1, 10, 0, Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0, 1000 * 60 * 60);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    //expected
    }
    try {
        new SimpleTimeZone(1000, "TEST", Calendar.DECEMBER, 1, Calendar.SUNDAY, 0, Calendar.NOVEMBER, -10, Calendar.SUNDAY, 0, 1000 * 60 * 60);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    //expected
    }
}
Also used : SimpleTimeZone(java.util.SimpleTimeZone) GregorianCalendar(java.util.GregorianCalendar)

Aggregations

SimpleTimeZone (java.util.SimpleTimeZone)114 TimeZone (java.util.TimeZone)42 GregorianCalendar (java.util.GregorianCalendar)34 Date (java.util.Date)25 SimpleDateFormat (java.text.SimpleDateFormat)20 Calendar (java.util.Calendar)8 Test (org.junit.Test)7 BasicDBObject (com.mongodb.BasicDBObject)3 BSONTimestamp (org.bson.types.BSONTimestamp)3 Code (org.bson.types.Code)3 CodeWScope (org.bson.types.CodeWScope)3 ObjectId (org.bson.types.ObjectId)3 Support_TimeZone (tests.support.Support_TimeZone)3 DBRef (com.mongodb.DBRef)2 IOException (java.io.IOException)2 InvalidObjectException (java.io.InvalidObjectException)2 DateFormat (java.text.DateFormat)2 ParsePosition (java.text.ParsePosition)2 Binary (org.bson.types.Binary)2 MaxKey (org.bson.types.MaxKey)2