Search in sources :

Example 61 with SimpleTimeZone

use of java.util.SimpleTimeZone in project j2objc by google.

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 62 with SimpleTimeZone

use of java.util.SimpleTimeZone in project j2objc by google.

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 63 with SimpleTimeZone

use of java.util.SimpleTimeZone in project j2objc by google.

the class SimpleTimeZoneTest method test_equalsLjava_lang_Object.

/**
     * java.util.SimpleTimeZone#equals(java.lang.Object)
     */
public void test_equalsLjava_lang_Object() {
    // Test for method boolean
    // java.util.SimpleTimeZone.equals(java.lang.Object)
    TimeZone tz = TimeZone.getTimeZone("EST");
    st1 = new SimpleTimeZone(tz.getRawOffset(), "EST");
    st2 = new SimpleTimeZone(0, "EST");
    assertFalse(st1.equals(st2));
    st1.setRawOffset(st2.getRawOffset());
    assertTrue(st1.equals(st2));
}
Also used : TimeZone(java.util.TimeZone) SimpleTimeZone(java.util.SimpleTimeZone) SimpleTimeZone(java.util.SimpleTimeZone)

Example 64 with SimpleTimeZone

use of java.util.SimpleTimeZone in project j2objc by google.

the class SimpleTimeZoneTest method test_ConstructorILjava_lang_StringIIIIIIIIIII.

/**
     * java.util.SimpleTimeZone#SimpleTimeZone(int, java.lang.String,
     *        int, int, int, int, int, int, int, int, int, int, int)
     */
public void test_ConstructorILjava_lang_StringIIIIIIIIIII() {
    // Test for method java.util.SimpleTimeZone(int, java.lang.String, int,
    // int, int, int, int, int, int, int, int, int, int)
    // TODO : Implement test
    //Regression for HARMONY-1241
    assertNotNull(new SimpleTimeZone(TimeZone.LONG, "Europe/Paris", SimpleTimeZone.STANDARD_TIME, SimpleTimeZone.STANDARD_TIME, SimpleTimeZone.UTC_TIME, SimpleTimeZone.WALL_TIME, SimpleTimeZone.WALL_TIME, TimeZone.SHORT, SimpleTimeZone.STANDARD_TIME, TimeZone.LONG, SimpleTimeZone.UTC_TIME, SimpleTimeZone.STANDARD_TIME, TimeZone.LONG));
    //seems RI doesn't check the startTimeMode and endTimeMode at all
    //this behavior is contradicts with spec
    assertNotNull(new SimpleTimeZone(TimeZone.LONG, "Europe/Paris", SimpleTimeZone.STANDARD_TIME, SimpleTimeZone.STANDARD_TIME, SimpleTimeZone.UTC_TIME, SimpleTimeZone.WALL_TIME, Integer.MAX_VALUE, TimeZone.SHORT, SimpleTimeZone.STANDARD_TIME, TimeZone.LONG, SimpleTimeZone.UTC_TIME, Integer.MIN_VALUE, TimeZone.LONG));
    try {
        new SimpleTimeZone(1000, "TEST", 12, 1, Calendar.SUNDAY, 0, Integer.MAX_VALUE, Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0, Integer.MAX_VALUE, 1000 * 60 * 60);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    //expected
    }
    try {
        new SimpleTimeZone(1000, "TEST", Calendar.NOVEMBER, 10, Calendar.SUNDAY, 0, Integer.MAX_VALUE, Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0, Integer.MAX_VALUE, 1000 * 60 * 60);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    //expected
    }
    try {
        new SimpleTimeZone(1000, "TEST", Calendar.NOVEMBER, 1, 10, 0, Calendar.NOVEMBER, Integer.MAX_VALUE, -1, Calendar.SUNDAY, 0, Integer.MAX_VALUE, 1000 * 60 * 60);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    //expected
    }
    try {
        new SimpleTimeZone(1000, "TEST", Calendar.DECEMBER, 1, Calendar.SUNDAY, 0, Calendar.NOVEMBER, Integer.MAX_VALUE, -10, Calendar.SUNDAY, 0, Integer.MAX_VALUE, 1000 * 60 * 60);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    //expected
    }
}
Also used : SimpleTimeZone(java.util.SimpleTimeZone)

Example 65 with SimpleTimeZone

use of java.util.SimpleTimeZone in project j2objc by google.

the class GregorianCalendarTest method test_computeTime_enteringDst.

public void test_computeTime_enteringDst() {
    // Get the DST entry time with a ZoneInfo implementation of TimeZone.
    TimeZone zoneInfo = TimeZone.getTimeZone("America/Los_Angeles");
    long zoneInfoTime = getDstLosAngeles2014(zoneInfo);
    // Check that the time is correct.
    assertTrue(zoneInfo.inDaylightTime(new Date(zoneInfoTime)));
    assertFalse(zoneInfo.inDaylightTime(new Date(zoneInfoTime - 1)));
    // Get the DST entry time with a SimpleTimeZone implementation of TimeZone.
    SimpleTimeZone simpleTimeZone = new SimpleTimeZone(-28800000, "Custom America/Los_Angeles", Calendar.MARCH, 9, 0, 7200000, Calendar.NOVEMBER, 2, 0, 7200000, 3600000);
    long simpleTimeZoneTime = getDstLosAngeles2014(simpleTimeZone);
}
Also used : TimeZone(java.util.TimeZone) SimpleTimeZone(java.util.SimpleTimeZone) SimpleTimeZone(java.util.SimpleTimeZone) Date(java.util.Date)

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