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)));
}
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
}
}
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));
}
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
}
}
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);
}
Aggregations