Search in sources :

Example 86 with SimpleTimeZone

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

the class SimpleTimeZoneTest method test_ConstructorILjava_lang_String.

/**
     * java.util.SimpleTimeZone#SimpleTimeZone(int, java.lang.String)
     */
public void test_ConstructorILjava_lang_String() {
    // Test for method java.util.SimpleTimeZone(int, java.lang.String)
    SimpleTimeZone st = new SimpleTimeZone(1000, "TEST");
    assertEquals("Incorrect TZ constructed", "TEST", st.getID());
    assertTrue("Incorrect TZ constructed: " + "returned wrong offset", st.getRawOffset() == 1000);
    assertTrue("Incorrect TZ constructed" + "using daylight savings", !st.useDaylightTime());
}
Also used : SimpleTimeZone(java.util.SimpleTimeZone)

Example 87 with SimpleTimeZone

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

the class SimpleTimeZoneTest method test_inDaylightTimeLjava_util_Date.

/**
     * java.util.SimpleTimeZone#inDaylightTime(java.util.Date)
     */
public void test_inDaylightTimeLjava_util_Date() {
    // Test for method boolean
    // java.util.SimpleTimeZone.inDaylightTime(java.util.Date)
    TimeZone tz = TimeZone.getTimeZone("EST");
    SimpleTimeZone zone = new SimpleTimeZone(tz.getRawOffset(), "EST", Calendar.APRIL, 1, -Calendar.SUNDAY, 7200000, Calendar.OCTOBER, -1, Calendar.SUNDAY, 7200000, 3600000);
    GregorianCalendar gc = new GregorianCalendar(1998, Calendar.JUNE, 11);
    assertTrue("Returned incorrect daylight value1", zone.inDaylightTime(gc.getTime()));
    gc = new GregorianCalendar(1998, Calendar.NOVEMBER, 11);
    assertTrue("Returned incorrect daylight value2", !(zone.inDaylightTime(gc.getTime())));
    gc = new GregorianCalendar(zone);
    gc.set(1999, Calendar.APRIL, 4, 1, 59, 59);
    assertTrue("Returned incorrect daylight value3", !(zone.inDaylightTime(gc.getTime())));
    Date date = new Date(gc.getTime().getTime() + 1000);
    assertTrue("Returned incorrect daylight value4", zone.inDaylightTime(date));
    gc.set(1999, Calendar.OCTOBER, 31, 1, 0, 0);
    assertTrue("Returned incorrect daylight value5", !(zone.inDaylightTime(gc.getTime())));
    date = new Date(gc.getTime().getTime() - 1000);
    assertTrue("Returned incorrect daylight value6", zone.inDaylightTime(date));
    assertTrue("Returned incorrect daylight value7", !zone.inDaylightTime(new Date(891752400000L + 7200000 - 1)));
    assertTrue("Returned incorrect daylight value8", zone.inDaylightTime(new Date(891752400000L + 7200000)));
    assertTrue("Returned incorrect daylight value9", zone.inDaylightTime(new Date(909288000000L + 7200000 - 1)));
    assertTrue("Returned incorrect daylight value10", !zone.inDaylightTime(new Date(909288000000L + 7200000)));
}
Also used : TimeZone(java.util.TimeZone) SimpleTimeZone(java.util.SimpleTimeZone) SimpleTimeZone(java.util.SimpleTimeZone) GregorianCalendar(java.util.GregorianCalendar) Date(java.util.Date)

Example 88 with SimpleTimeZone

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

the class SimpleTimeZoneTest method test_setEndRuleIII.

/**
     * java.util.SimpleTimeZone#setEndRule(int, int, int)
     */
public void test_setEndRuleIII() {
    SimpleTimeZone st = new SimpleTimeZone(1000, "Test_TZ");
    st.setStartRule(Calendar.NOVEMBER, 1, 0);
    st.setEndRule(Calendar.NOVEMBER, 20, 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.setEndRule(13, 20, 0);
        fail("IllegalArgumentException is not thrown.");
    } catch (IllegalArgumentException iae) {
    //expected
    }
    try {
        st.setEndRule(1, 32, 0);
        fail("IllegalArgumentException is not thrown.");
    } catch (IllegalArgumentException iae) {
    //expected
    }
    try {
        st.setEndRule(1, 30, 10);
        fail("IllegalArgumentException is not thrown.");
    } catch (IllegalArgumentException iae) {
    //expected
    }
}
Also used : SimpleTimeZone(java.util.SimpleTimeZone) GregorianCalendar(java.util.GregorianCalendar)

Example 89 with SimpleTimeZone

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

the class SimpleTimeZoneTest method test_getOffsetIIIIII.

/**
     * java.util.SimpleTimeZone#getOffset(int, int, int, int, int, int)
     */
public void test_getOffsetIIIIII() {
    // Test for method int java.util.SimpleTimeZone.getOffset(int, int, int,
    // int, int, int)
    //        TimeZone st1 = TimeZone.getTimeZone("EST");
    st1 = new SimpleTimeZone(TimeZone.getTimeZone("EST").getRawOffset(), "EST");
    assertTrue("Incorrect offset returned", st1.getOffset(GregorianCalendar.AD, 1998, Calendar.NOVEMBER, 11, Calendar.WEDNESDAY, 0) == -(5 * 60 * 60 * 1000));
    st1 = new SimpleTimeZone(TimeZone.getTimeZone("EST").getRawOffset(), "EST");
    assertEquals("Incorrect offset returned", -(5 * 60 * 60 * 1000), st1.getOffset(GregorianCalendar.AD, 1998, Calendar.JUNE, 11, Calendar.THURSDAY, 0));
    // Regression for HARMONY-5459
    st1 = new SimpleTimeZone(TimeZone.getDefault().getRawOffset(), TimeZone.getDefault().getID());
    int fourHours = 4 * 60 * 60 * 1000;
    st1.setRawOffset(fourHours);
    assertEquals(fourHours, st1.getOffset(1, 2099, 01, 1, 5, 0));
    try {
        st1.getOffset(-1, 2099, 01, 1, 5, 0);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    //expected
    }
    try {
        st1.getOffset(1, 2099, 15, 1, 5, 0);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    //expected
    }
    try {
        st1.getOffset(1, 2099, 01, 100, 5, 0);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    //expected
    }
    try {
        st1.getOffset(1, 2099, 01, 1, 50, 0);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    //expected
    }
    try {
        st1.getOffset(1, 2099, 01, 1, 5, -10);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    //expected
    }
}
Also used : SimpleTimeZone(java.util.SimpleTimeZone)

Example 90 with SimpleTimeZone

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

the class SimpleTimeZoneTest method test_getRawOffset.

/**
     * java.util.SimpleTimeZone#getRawOffset()
     */
public void test_getRawOffset() {
    // Test for method int java.util.SimpleTimeZone.getRawOffset()
    st1 = new SimpleTimeZone(TimeZone.getTimeZone("EST").getRawOffset(), "EST");
    assertTrue("Incorrect offset returned", st1.getRawOffset() == -(5 * 60 * 60 * 1000));
}
Also used : SimpleTimeZone(java.util.SimpleTimeZone)

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