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