use of java.util.SimpleTimeZone in project j2objc by google.
the class SimpleTimeZoneTest method test_setStartRuleIIII.
/**
* java.util.SimpleTimeZone#setStartRule(int, int, int, int)
*/
public void test_setStartRuleIIII() {
// Test for method void java.util.SimpleTimeZone.setStartRule(int, int,
// int, int)
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, 1, Calendar.SUNDAY, 0);
st.setEndRule(Calendar.NOVEMBER, -1, Calendar.SUNDAY, 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.setStartRule(12, -1, Calendar.SUNDAY, 0);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
try {
st.setStartRule(Calendar.NOVEMBER, 10, Calendar.SUNDAY, 0);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
try {
st.setStartRule(Calendar.NOVEMBER, -1, 8, 0);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
try {
st.setStartRule(Calendar.NOVEMBER, -1, Calendar.SUNDAY, -10);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
}
use of java.util.SimpleTimeZone in project j2objc by google.
the class SimpleTimeZoneTest method test_setRawOffsetI.
/**
* java.util.SimpleTimeZone#setRawOffset(int)
*/
public void test_setRawOffsetI() {
// Test for method void java.util.SimpleTimeZone.setRawOffset(int)
st1 = new SimpleTimeZone(TimeZone.getTimeZone("EST").getRawOffset(), "EST");
int off = st1.getRawOffset();
st1.setRawOffset(1000);
boolean val = st1.getRawOffset() == 1000;
st1.setRawOffset(off);
assertTrue("Incorrect offset set", val);
}
use of java.util.SimpleTimeZone in project j2objc by google.
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
}
}
use of java.util.SimpleTimeZone in project j2objc by google.
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 j2objc by google.
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