use of java.util.TimeZone in project robovm by robovm.
the class TimeZoneTest method testSantiago.
public void testSantiago() throws Exception {
TimeZone tz = TimeZone.getTimeZone("America/Santiago");
assertEquals("Chile Summer Time", tz.getDisplayName(true, TimeZone.LONG, Locale.US));
assertEquals("Chile Standard Time", tz.getDisplayName(false, TimeZone.LONG, Locale.US));
assertEquals("GMT-03:00", tz.getDisplayName(true, TimeZone.SHORT, Locale.US));
assertEquals("GMT-04:00", tz.getDisplayName(false, TimeZone.SHORT, Locale.US));
}
use of java.util.TimeZone in project robovm by robovm.
the class TimeZoneTest method testZeroTransitionZones.
public void testZeroTransitionZones() throws Exception {
// Zones with no transitions historical or future seem ideal for testing.
String[] ids = new String[] { "Africa/Bujumbura", "Indian/Cocos", "Pacific/Wake", "UTC" };
for (String id : ids) {
TimeZone tz = TimeZone.getTimeZone(id);
assertFalse(tz.useDaylightTime());
assertFalse(tz.inDaylightTime(new Date(Integer.MIN_VALUE)));
assertFalse(tz.inDaylightTime(new Date(0)));
assertFalse(tz.inDaylightTime(new Date(Integer.MAX_VALUE)));
int currentOffset = tz.getOffset(new Date(0).getTime());
assertEquals(currentOffset, tz.getOffset(new Date(Integer.MIN_VALUE).getTime()));
assertEquals(currentOffset, tz.getOffset(new Date(Integer.MAX_VALUE).getTime()));
}
}
use of java.util.TimeZone in project robovm by robovm.
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 robovm by robovm.
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 robovm by robovm.
the class OldAndroidLocaleTest method testResourceBundles.
public void testResourceBundles() throws Exception {
Locale eng = new Locale("en", "US");
DateFormatSymbols engSymbols = new DateFormatSymbols(eng);
Locale deu = new Locale("de", "DE");
DateFormatSymbols deuSymbols = new DateFormatSymbols(deu);
TimeZone berlin = TimeZone.getTimeZone("Europe/Berlin");
assertEquals("January", engSymbols.getMonths()[0]);
assertEquals("Januar", deuSymbols.getMonths()[0]);
assertEquals("Sunday", engSymbols.getWeekdays()[Calendar.SUNDAY]);
assertEquals("Sonntag", deuSymbols.getWeekdays()[Calendar.SUNDAY]);
assertEquals("Central European Standard Time", berlin.getDisplayName(false, TimeZone.LONG, eng));
assertEquals("Central European Summer Time", berlin.getDisplayName(true, TimeZone.LONG, eng));
assertEquals("Mitteleuropäische Normalzeit", berlin.getDisplayName(false, TimeZone.LONG, deu));
assertEquals("Mitteleuropäische Sommerzeit", berlin.getDisplayName(true, TimeZone.LONG, deu));
assertTrue(engSymbols.getZoneStrings().length > 100);
}
Aggregations