use of java.util.SimpleTimeZone in project robovm by robovm.
the class SimpleTimeZoneTest method test_setEndRuleIIIIZ.
/**
* java.util.SimpleTimeZone#setEndRule(int, int, int, int, boolean)
*/
public void test_setEndRuleIIIIZ() {
// Test for method void java.util.SimpleTimeZone.setEndRule(int, int,
// int, int, boolean)
SimpleTimeZone st = new SimpleTimeZone(1000, "Test_TZ");
// Spec indicates that both end and start must be set or result is
// undefined
st.setStartRule(Calendar.NOVEMBER, 8, Calendar.SUNDAY, 1, false);
st.setEndRule(Calendar.NOVEMBER, 15, Calendar.SUNDAY, 1, true);
assertTrue("StartRule improperly set1", st.useDaylightTime());
assertTrue("StartRule improperly set2", st.inDaylightTime((new GregorianCalendar(1999, Calendar.NOVEMBER, 7, 12, 0).getTime())));
assertTrue("StartRule improperly set3", st.inDaylightTime((new GregorianCalendar(1999, Calendar.NOVEMBER, 20, 12, 0).getTime())));
assertTrue("StartRule improperly set4", !(st.inDaylightTime(new GregorianCalendar(1999, Calendar.NOVEMBER, 6, 12, 0).getTime())));
assertTrue("StartRule improperly set5", !(st.inDaylightTime(new GregorianCalendar(1999, Calendar.NOVEMBER, 21, 12, 0).getTime())));
try {
st.setEndRule(20, 15, Calendar.SUNDAY, 1, true);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
try {
st.setEndRule(Calendar.NOVEMBER, 35, Calendar.SUNDAY, 1, true);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
try {
st.setEndRule(Calendar.NOVEMBER, 15, 12, 1, true);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
try {
st.setEndRule(Calendar.NOVEMBER, 15, Calendar.SUNDAY, -1, true);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
}
use of java.util.SimpleTimeZone in project robovm by robovm.
the class SimpleTimeZoneTest method test_hasSameRulesLjava_util_TimeZone.
/**
* java.util.SimpleTimeZone#hasSameRules(java.util.TimeZone)
*/
public void test_hasSameRulesLjava_util_TimeZone() {
// Test for method boolean
// java.util.SimpleTimeZone.hasSameRules(java.util.TimeZone)
SimpleTimeZone st = new SimpleTimeZone(1000, "TEST", Calendar.NOVEMBER, 1, Calendar.SUNDAY, 0, Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0);
SimpleTimeZone sameAsSt = new SimpleTimeZone(1000, "REST", Calendar.NOVEMBER, 1, Calendar.SUNDAY, 0, Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0);
SimpleTimeZone notSameAsSt = new SimpleTimeZone(1000, "PEST", Calendar.NOVEMBER, 2, Calendar.SUNDAY, 0, Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0);
assertTrue("Time zones have same rules but return false", st.hasSameRules(sameAsSt));
assertTrue("Time zones have different rules but return true", !st.hasSameRules(notSameAsSt));
}
use of java.util.SimpleTimeZone in project robovm by robovm.
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 robovm by robovm.
the class SimpleTimeZoneTest method test_setStartYearI.
/**
* java.util.SimpleTimeZone#setStartYear(int)
*/
public void test_setStartYearI() {
// Test for method void java.util.SimpleTimeZone.setStartYear(int)
SimpleTimeZone st = new SimpleTimeZone(1000, "Test_TZ");
st.setStartRule(Calendar.NOVEMBER, 1, Calendar.SUNDAY, 0);
st.setEndRule(Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0);
st.setStartYear(1999);
assertTrue("set year improperly set1", !(st.inDaylightTime(new GregorianCalendar(1999, Calendar.JULY, 12).getTime())));
assertTrue("set year improperly set2", !(st.inDaylightTime(new GregorianCalendar(1998, Calendar.OCTOBER, 13).getTime())));
assertTrue("set year improperly set3", (st.inDaylightTime(new GregorianCalendar(1999, Calendar.NOVEMBER, 13).getTime())));
}
use of java.util.SimpleTimeZone in project robovm by robovm.
the class SimpleTimeZoneTest method test_setStartRuleIIIIZ.
/**
* java.util.SimpleTimeZone#setStartRule(int, int, int, int, boolean)
*/
public void test_setStartRuleIIIIZ() {
TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
// Test for method void java.util.SimpleTimeZone.setStartRule(int, int,
// int, int, boolean)
SimpleTimeZone st = new SimpleTimeZone(TimeZone.getTimeZone("EST").getRawOffset(), "EST");
// Spec indicates that both end and start must be set or result is
// undefined
st.setStartRule(Calendar.NOVEMBER, 1, Calendar.SUNDAY, 1, true);
st.setEndRule(Calendar.NOVEMBER, 15, Calendar.SUNDAY, 1, false);
assertTrue("StartRule improperly set1", st.useDaylightTime());
assertTrue("StartRule improperly set2", st.inDaylightTime((new GregorianCalendar(1999, Calendar.NOVEMBER, 7, 12, 0).getTime())));
assertTrue("StartRule improperly set3", st.inDaylightTime((new GregorianCalendar(1999, Calendar.NOVEMBER, 13, 12, 0).getTime())));
assertTrue("StartRule improperly set4", !(st.inDaylightTime(new GregorianCalendar(1999, Calendar.NOVEMBER, 6, 12, 0).getTime())));
assertTrue("StartRule improperly set5", !(st.inDaylightTime(new GregorianCalendar(1999, Calendar.NOVEMBER, 14, 12, 0).getTime())));
try {
st.setStartRule(20, 15, Calendar.SUNDAY, 1, true);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
try {
st.setStartRule(Calendar.NOVEMBER, 35, Calendar.SUNDAY, 1, true);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
try {
st.setStartRule(Calendar.NOVEMBER, 15, 12, 1, true);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
try {
st.setStartRule(Calendar.NOVEMBER, 15, Calendar.SUNDAY, -1, true);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
}
Aggregations