use of java.util.GregorianCalendar in project j2objc by google.
the class GregorianCalendarTest method test_getActualMaximumI.
/**
* java.util.GregorianCalendar#getActualMaximum(int)
*/
public void test_getActualMaximumI() {
// Test for method int java.util.GregorianCalendar.getActualMaximum(int)
GregorianCalendar gc1 = new GregorianCalendar(1900, 1, 1);
GregorianCalendar gc2 = new GregorianCalendar(1996, 1, 1);
GregorianCalendar gc3 = new GregorianCalendar(1997, 1, 1);
GregorianCalendar gc4 = new GregorianCalendar(2000, 1, 1);
GregorianCalendar gc5 = new GregorianCalendar(2000, 9, 9);
GregorianCalendar gc6 = new GregorianCalendar(2000, 3, 3);
assertEquals("Wrong actual maximum value for DAY_OF_MONTH for Feb 1900", 28, gc1.getActualMaximum(Calendar.DAY_OF_MONTH));
assertEquals("Wrong actual maximum value for DAY_OF_MONTH for Feb 1996", 29, gc2.getActualMaximum(Calendar.DAY_OF_MONTH));
assertEquals("Wrong actual maximum value for DAY_OF_MONTH for Feb 1998", 28, gc3.getActualMaximum(Calendar.DAY_OF_MONTH));
assertEquals("Wrong actual maximum value for DAY_OF_MONTH for Feb 2000", 29, gc4.getActualMaximum(Calendar.DAY_OF_MONTH));
assertEquals("Wrong actual maximum value for DAY_OF_MONTH for Oct 2000", 31, gc5.getActualMaximum(Calendar.DAY_OF_MONTH));
assertEquals("Wrong actual maximum value for DAY_OF_MONTH for Apr 2000", 30, gc6.getActualMaximum(Calendar.DAY_OF_MONTH));
assertTrue("Wrong actual maximum value for MONTH", gc1.getActualMaximum(Calendar.MONTH) == Calendar.DECEMBER);
assertEquals("Wrong actual maximum value for HOUR_OF_DAY", 23, gc1.getActualMaximum(Calendar.HOUR_OF_DAY));
assertEquals("Wrong actual maximum value for HOUR", 11, gc1.getActualMaximum(Calendar.HOUR));
assertEquals("Wrong actual maximum value for DAY_OF_WEEK_IN_MONTH", 4, gc6.getActualMaximum(Calendar.DAY_OF_WEEK_IN_MONTH));
// Regression test for harmony 2954
Date date = new Date(Date.parse("Jan 15 00:00:01 GMT 2000"));
GregorianCalendar gc = new GregorianCalendar();
gc.setTimeInMillis(Date.parse("Dec 15 00:00:01 GMT 1582"));
assertEquals(355, gc.getActualMaximum(Calendar.DAY_OF_YEAR));
gc.setGregorianChange(date);
gc.setTimeInMillis(Date.parse("Jan 16 00:00:01 GMT 2000"));
assertEquals(353, gc.getActualMaximum(Calendar.DAY_OF_YEAR));
//Regression test for HARMONY-3004
gc = new GregorianCalendar(1900, 7, 1);
String[] ids = TimeZone.getAvailableIDs();
for (int i = 0; i < ids.length; i++) {
TimeZone tz = TimeZone.getTimeZone(ids[i]);
gc.setTimeZone(tz);
for (int j = 1900; j < 2000; j++) {
gc.set(Calendar.YEAR, j);
assertEquals(7200000, gc.getActualMaximum(Calendar.DST_OFFSET));
}
}
}
use of java.util.GregorianCalendar in project j2objc by google.
the class GregorianCalendarTest method test_ConstructorIIIIII.
/**
* java.util.GregorianCalendar#GregorianCalendar(int, int, int, int,
*int, int)
*/
public void test_ConstructorIIIIII() {
// Test for method java.util.GregorianCalendar(int, int, int, int, int,
// int)
GregorianCalendar gc = new GregorianCalendar(1972, Calendar.OCTOBER, 13, 19, 9, 59);
assertEquals("Incorrect calendar constructed", 1972, gc.get(Calendar.YEAR));
assertTrue("Incorrect calendar constructed", gc.get(Calendar.MONTH) == Calendar.OCTOBER);
assertEquals("Incorrect calendar constructed", 13, gc.get(Calendar.DAY_OF_MONTH));
assertEquals("Incorrect calendar constructed", 7, gc.get(Calendar.HOUR));
assertEquals("Incorrect calendar constructed", 1, gc.get(Calendar.AM_PM));
assertEquals("Incorrect calendar constructed", 9, gc.get(Calendar.MINUTE));
assertEquals("Incorrect calendar constructed", 59, gc.get(Calendar.SECOND));
assertTrue("Incorrect calendar constructed", gc.getTimeZone().equals(TimeZone.getDefault()));
}
use of java.util.GregorianCalendar 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));
}
use of java.util.GregorianCalendar in project j2objc by google.
the class SimpleTimeZoneTest method test_setStartRuleIII.
/**
* java.util.SimpleTimeZone#setStartRule(int, int, int)
*/
public void test_setStartRuleIII() {
// Test for method void java.util.SimpleTimeZone.setStartRule(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, 1);
st.setEndRule(Calendar.DECEMBER, 1, 1);
assertTrue("StartRule improperly set", st.useDaylightTime());
assertTrue("StartRule improperly set", st.inDaylightTime((new GregorianCalendar(1998, Calendar.NOVEMBER, 13).getTime())));
assertTrue("StartRule improperly set", !(st.inDaylightTime(new GregorianCalendar(1998, Calendar.OCTOBER, 13).getTime())));
try {
st.setStartRule(13, 20, 0);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
try {
st.setStartRule(1, 32, 0);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
try {
st.setStartRule(1, 30, 10);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
}
use of java.util.GregorianCalendar in project j2objc by google.
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())));
}
Aggregations