use of java.util.TimeZone in project j2objc by google.
the class OldTimeZoneTest method test_getDisplayName.
public void test_getDisplayName() {
Locale.setDefault(Locale.US);
TimeZone tz = TimeZone.getTimeZone("GMT-6");
assertEquals("GMT-06:00", tz.getDisplayName());
tz = TimeZone.getTimeZone("America/Los_Angeles");
assertEquals("Pacific Standard Time", tz.getDisplayName());
}
use of java.util.TimeZone in project j2objc by google.
the class OldTimeZoneTest method test_setIDLjava_lang_String.
public void test_setIDLjava_lang_String() {
TimeZone tz = TimeZone.getTimeZone("GMT-6");
assertEquals("GMT-06:00", tz.getID());
tz.setID("New ID for GMT-6");
assertEquals("New ID for GMT-6", tz.getID());
}
use of java.util.TimeZone in project j2objc by google.
the class OldTimeZoneTest method test_hasSameRulesLjava_util_TimeZone.
public void test_hasSameRulesLjava_util_TimeZone() {
TimeZone tz1 = TimeZone.getTimeZone("America/Denver");
TimeZone tz2 = TimeZone.getTimeZone("America/Phoenix");
assertEquals(tz1.getDisplayName(false, 0), tz2.getDisplayName(false, 0));
// Arizona doesn't observe DST. See http://phoenix.about.com/cs/weather/qt/timezone.htm
assertFalse(tz1.hasSameRules(tz2));
assertFalse(tz1.hasSameRules(null));
tz1 = TimeZone.getTimeZone("America/New_York");
tz2 = TimeZone.getTimeZone("US/Eastern");
assertEquals(tz1.getDisplayName(), tz2.getDisplayName());
assertFalse(tz1.getID().equals(tz2.getID()));
assertTrue(tz2.hasSameRules(tz1));
assertTrue(tz1.hasSameRules(tz1));
}
use of java.util.TimeZone in project j2objc by google.
the class OldTimeZoneTest method test_getID.
public void test_getID() {
TimeZone tz = TimeZone.getTimeZone("GMT-6");
assertEquals("GMT-06:00", tz.getID());
tz = TimeZone.getTimeZone("America/Denver");
assertEquals("America/Denver", tz.getID());
}
use of java.util.TimeZone 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));
}
}
}
Aggregations