use of java.util.GregorianCalendar in project j2objc by google.
the class SimpleTimeZoneTest method test_ConstructorILjava_lang_StringIIIIIIIII.
/**
* java.util.SimpleTimeZone#SimpleTimeZone(int, java.lang.String,
* int, int, int, int, int, int, int, int, int)
*/
public void test_ConstructorILjava_lang_StringIIIIIIIII() {
// Test for method java.util.SimpleTimeZone(int, java.lang.String, int,
// 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, 1000 * 60 * 60);
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());
assertTrue("Incorrect TZ constructed", st.getDSTSavings() == 1000 * 60 * 60);
try {
new SimpleTimeZone(1000, "TEST", 12, 1, Calendar.SUNDAY, 0, Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0, 1000 * 60 * 60);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException e) {
//expected
}
try {
new SimpleTimeZone(1000, "TEST", Calendar.NOVEMBER, 10, Calendar.SUNDAY, 0, Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0, 1000 * 60 * 60);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException e) {
//expected
}
try {
new SimpleTimeZone(1000, "TEST", Calendar.NOVEMBER, 1, 10, 0, Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0, 1000 * 60 * 60);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException e) {
//expected
}
try {
new SimpleTimeZone(1000, "TEST", Calendar.DECEMBER, 1, Calendar.SUNDAY, 0, Calendar.NOVEMBER, -10, Calendar.SUNDAY, 0, 1000 * 60 * 60);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException e) {
//expected
}
}
use of java.util.GregorianCalendar in project j2objc by google.
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.GregorianCalendar in project j2objc by google.
the class GregorianCalendarTest method test_ConstructorLjava_util_TimeZoneLjava_util_Locale.
/**
* java.util.GregorianCalendar#GregorianCalendar(java.util.TimeZone,
*java.util.Locale)
*/
public void test_ConstructorLjava_util_TimeZoneLjava_util_Locale() {
// Test for method java.util.GregorianCalendar(java.util.TimeZone,
// java.util.Locale)
Date date = new Date(2008, 1, 1);
TimeZone.getDefault();
GregorianCalendar gc1 = new GregorianCalendar(AMERICA_NEW_YORK, Locale.JAPAN);
gc1.setTime(date);
GregorianCalendar gc2 = new GregorianCalendar(AMERICA_NEW_YORK, Locale.JAPAN);
gc2.setTime(date);
GregorianCalendar gc3 = new GregorianCalendar(AMERICA_CHICAGO, Locale.ITALY);
gc3.setTime(date);
// Chicago is 1 hour before New York, add 1 to the Chicago time and convert to 0-12 value
assertEquals("Incorrect calendar returned", gc1.get(Calendar.HOUR), ((gc3.get(Calendar.HOUR) + 1) % 12));
assertTrue("Locales not created correctly", gc1.equals(gc2) && !gc1.equals(gc3));
}
use of java.util.GregorianCalendar in project j2objc by google.
the class GregorianCalendarTest method test_getGregorianChange.
/**
* java.util.GregorianCalendar#getGregorianChange()
*/
public void test_getGregorianChange() {
// Test for method java.util.Date
// java.util.GregorianCalendar.getGregorianChange()
GregorianCalendar gc = new GregorianCalendar();
GregorianCalendar returnedChange = new GregorianCalendar(AMERICA_NEW_YORK);
returnedChange.setTime(gc.getGregorianChange());
assertEquals("Returned incorrect year", 1582, returnedChange.get(Calendar.YEAR));
assertTrue("Returned incorrect month", returnedChange.get(Calendar.MONTH) == Calendar.OCTOBER);
assertEquals("Returned incorrect day of month", 4, returnedChange.get(Calendar.DAY_OF_MONTH));
}
use of java.util.GregorianCalendar in project j2objc by google.
the class GregorianCalendarTest method test_getGreatestMinimumI.
/**
* java.util.GregorianCalendar#getGreatestMinimum(int)
*/
public void test_getGreatestMinimumI() {
// Test for method int
// java.util.GregorianCalendar.getGreatestMinimum(int)
GregorianCalendar gc = new GregorianCalendar();
assertEquals("Wrong greatest minimum value for DAY_OF_MONTH", 1, gc.getGreatestMinimum(Calendar.DAY_OF_MONTH));
assertTrue("Wrong greatest minimum value for MONTH", gc.getGreatestMinimum(Calendar.MONTH) == Calendar.JANUARY);
assertEquals("Wrong greatest minimum value for HOUR_OF_DAY", 0, gc.getGreatestMinimum(Calendar.HOUR_OF_DAY));
assertEquals("Wrong greatest minimum value for HOUR", 0, gc.getGreatestMinimum(Calendar.HOUR));
BitSet result = new BitSet();
int[] min = { 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, -46800000, 0 };
for (int i = 0; i < min.length; i++) {
if (gc.getGreatestMinimum(i) != min[i])
result.set(i);
}
assertTrue("Wrong greatest min for " + result, result.length() == 0);
}
Aggregations