Search in sources :

Example 76 with TimeZone

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));
}
Also used : TimeZone(java.util.TimeZone) SimpleTimeZone(java.util.SimpleTimeZone)

Example 77 with TimeZone

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()));
    }
}
Also used : TimeZone(java.util.TimeZone) SimpleTimeZone(java.util.SimpleTimeZone) Date(java.util.Date)

Example 78 with TimeZone

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());
}
Also used : TimeZone(java.util.TimeZone)

Example 79 with TimeZone

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));
}
Also used : TimeZone(java.util.TimeZone)

Example 80 with TimeZone

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);
}
Also used : Locale(java.util.Locale) TimeZone(java.util.TimeZone) DateFormatSymbols(java.text.DateFormatSymbols)

Aggregations

TimeZone (java.util.TimeZone)577 Date (java.util.Date)140 Calendar (java.util.Calendar)137 SimpleTimeZone (java.util.SimpleTimeZone)89 Test (org.junit.Test)85 SimpleDateFormat (java.text.SimpleDateFormat)69 Locale (java.util.Locale)69 GregorianCalendar (java.util.GregorianCalendar)56 ArrayList (java.util.ArrayList)32 DateFormat (java.text.DateFormat)24 ParseException (java.text.ParseException)23 IOException (java.io.IOException)20 Map (java.util.Map)15 HashSet (java.util.HashSet)13 PreparedStatement (java.sql.PreparedStatement)11 HashMap (java.util.HashMap)11 DateTimeZone (org.joda.time.DateTimeZone)11 Support_TimeZone (tests.support.Support_TimeZone)10 Resources (android.content.res.Resources)9 SQLException (java.sql.SQLException)9