use of java.util.TimeZone 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.TimeZone in project j2objc by google.
the class TimeZoneTest method test_setDefaultLjava_util_TimeZone.
/**
* java.util.TimeZone#setDefault(java.util.TimeZone)
*/
public void test_setDefaultLjava_util_TimeZone() {
// NOTE: Required to get tests passing under vogar. Vogar sets
// a hardcoded timezone before running every test, so we have to
// set it back to the "real" default before we run the test.
TimeZone.setDefault(null);
TimeZone oldDefault = TimeZone.getDefault();
TimeZone zone = new SimpleTimeZone(45, "TEST");
TimeZone.setDefault(zone);
assertEquals("timezone not set", zone, TimeZone.getDefault());
TimeZone.setDefault(null);
assertEquals("default not restored", oldDefault, TimeZone.getDefault());
}
use of java.util.TimeZone in project j2objc by google.
the class TimeZoneTest method test_getDSTSavings.
/**
* java.util.TimeZone#getDSTSavings()
*/
public void test_getDSTSavings() {
// Test for method int java.util.TimeZone.getDSTSavings()
// test on subclass SimpleTimeZone
TimeZone st1 = TimeZone.getTimeZone("America/New_York");
assertEquals("T1A. Incorrect daylight savings returned", ONE_HOUR, st1.getDSTSavings());
// a SimpleTimeZone with daylight savings different then 1 hour
st1 = TimeZone.getTimeZone("Australia/Lord_Howe");
assertEquals("T1B. Incorrect daylight savings returned", 1800000, st1.getDSTSavings());
// test on subclass Support_TimeZone, an instance with daylight savings
TimeZone tz1 = new Support_TimeZone(-5 * ONE_HOUR, true);
assertEquals("T2. Incorrect daylight savings returned", ONE_HOUR, tz1.getDSTSavings());
// an instance without daylight savings
tz1 = new Support_TimeZone(3 * ONE_HOUR, false);
assertEquals("T3. Incorrect daylight savings returned, ", 0, tz1.getDSTSavings());
}
use of java.util.TimeZone in project j2objc by google.
the class TimeZoneTest method test_getDisplayName_ZI.
/**
* @add test {@link java.util.TimeZone#getDisplayName(boolean, int)}
*/
public void test_getDisplayName_ZI() {
TimeZone defaultZone = TimeZone.getDefault();
Locale defaultLocale = Locale.getDefault();
String actualName = defaultZone.getDisplayName(false, TimeZone.LONG);
String expectedName = defaultZone.getDisplayName(false, TimeZone.LONG, defaultLocale);
assertEquals("getDisplayName(daylight,style) did not return the default locale suitable name", expectedName, actualName);
}
use of java.util.TimeZone in project j2objc by google.
the class TimeZoneTest method test_getAvailableIDs_I.
public void test_getAvailableIDs_I() {
TimeZone tz = TimeZone.getTimeZone("Asia/Shanghai");
int rawoffset = tz.getRawOffset();
String[] ids = TimeZone.getAvailableIDs(rawoffset);
List<String> idList = Arrays.asList(ids);
assertTrue(idList.toString(), idList.contains("Asia/Hong_Kong"));
}
Aggregations