Search in sources :

Example 1 with Support_TimeZone

use of tests.support.Support_TimeZone in project j2objc by google.

the class TimeZoneTest method test_getOffset_long.

/**
 * java.util.TimeZone#getOffset(long)
 */
public void test_getOffset_long() {
    // Test for method int java.util.TimeZone.getOffset(long time)
    // test on subclass SimpleTimeZone
    TimeZone st1 = TimeZone.getTimeZone("EST");
    long time1 = new GregorianCalendar(1998, Calendar.NOVEMBER, 11).getTimeInMillis();
    assertEquals("T1. Incorrect offset returned", -(5 * ONE_HOUR), st1.getOffset(time1));
    long time2 = new GregorianCalendar(1998, Calendar.JUNE, 11).getTimeInMillis();
    st1 = TimeZone.getTimeZone("EST");
    assertEquals("T2. Incorrect offset returned", -(5 * ONE_HOUR), st1.getOffset(time2));
    // test on subclass Support_TimeZone, an instance with daylight savings
    TimeZone tz1 = new Support_TimeZone(-5 * ONE_HOUR, true);
    assertEquals("T3. Incorrect offset returned, ", -(5 * ONE_HOUR), tz1.getOffset(time1));
    assertEquals("T4. Incorrect offset returned, ", -(4 * ONE_HOUR), tz1.getOffset(time2));
    // an instance without daylight savings
    tz1 = new Support_TimeZone(3 * ONE_HOUR, false);
    assertEquals("T5. Incorrect offset returned, ", (3 * ONE_HOUR), tz1.getOffset(time1));
    assertEquals("T6. Incorrect offset returned, ", (3 * ONE_HOUR), tz1.getOffset(time2));
}
Also used : TimeZone(java.util.TimeZone) Support_TimeZone(tests.support.Support_TimeZone) SimpleTimeZone(java.util.SimpleTimeZone) NativeTimeZoneTest.isNativeTimeZone(com.google.j2objc.util.NativeTimeZoneTest.isNativeTimeZone) GregorianCalendar(java.util.GregorianCalendar) Support_TimeZone(tests.support.Support_TimeZone)

Example 2 with Support_TimeZone

use of tests.support.Support_TimeZone in project j2objc by google.

the class TimeZoneTest method test_getDSTSavings.

/**
 * java.util.TimeZone#getDSTSavings()
 */
public void test_getDSTSavings() {
    // Test for method int java.util.TimeZone.getDSTSavings()
    // test on subclass SimpleTimeZone
    TimeZone st1 = TimeZone.getTimeZone("America/New_York");
    assertEquals("T1A. Incorrect daylight savings returned", ONE_HOUR, st1.getDSTSavings());
    // a SimpleTimeZone with daylight savings different then 1 hour
    st1 = TimeZone.getTimeZone("Australia/Lord_Howe");
    assertEquals("T1B. Incorrect daylight savings returned", 1800000, st1.getDSTSavings());
    // test on subclass Support_TimeZone, an instance with daylight savings
    TimeZone tz1 = new Support_TimeZone(-5 * ONE_HOUR, true);
    assertEquals("T2. Incorrect daylight savings returned", ONE_HOUR, tz1.getDSTSavings());
    // an instance without daylight savings
    tz1 = new Support_TimeZone(3 * ONE_HOUR, false);
    assertEquals("T3. Incorrect daylight savings returned, ", 0, tz1.getDSTSavings());
}
Also used : TimeZone(java.util.TimeZone) Support_TimeZone(tests.support.Support_TimeZone) SimpleTimeZone(java.util.SimpleTimeZone) NativeTimeZoneTest.isNativeTimeZone(com.google.j2objc.util.NativeTimeZoneTest.isNativeTimeZone) Support_TimeZone(tests.support.Support_TimeZone)

Aggregations

NativeTimeZoneTest.isNativeTimeZone (com.google.j2objc.util.NativeTimeZoneTest.isNativeTimeZone)2 SimpleTimeZone (java.util.SimpleTimeZone)2 TimeZone (java.util.TimeZone)2 Support_TimeZone (tests.support.Support_TimeZone)2 GregorianCalendar (java.util.GregorianCalendar)1