use of android.icu.util.TimeZone in project j2objc by google.
the class IBMCalendarTest method TestSkippedWallTime.
@Test
public void TestSkippedWallTime() {
final Object[][] TESTDATA = { // Time zone Input wall time Valid wall time?
{ "America/New_York", new CalFields(2011, 3, 13, 1, 59, 59), true, // WALLTIME_LAST in GMT WALLTIME_FIRST in GMT WALLTIME_NEXT_VALID in GMT
new CalFields(2011, 3, 13, 6, 59, 59), new CalFields(2011, 3, 13, 6, 59, 59), new CalFields(2011, 3, 13, 6, 59, 59) }, { "America/New_York", new CalFields(2011, 3, 13, 2, 0, 0), false, new CalFields(2011, 3, 13, 7, 0, 0), new CalFields(2011, 3, 13, 6, 0, 0), new CalFields(2011, 3, 13, 7, 0, 0) }, { "America/New_York", new CalFields(2011, 3, 13, 2, 1, 0), false, new CalFields(2011, 3, 13, 7, 1, 0), new CalFields(2011, 3, 13, 6, 1, 0), new CalFields(2011, 3, 13, 7, 0, 0) }, { "America/New_York", new CalFields(2011, 3, 13, 2, 30, 0), false, new CalFields(2011, 3, 13, 7, 30, 0), new CalFields(2011, 3, 13, 6, 30, 0), new CalFields(2011, 3, 13, 7, 0, 0) }, { "America/New_York", new CalFields(2011, 3, 13, 2, 59, 59), false, new CalFields(2011, 3, 13, 7, 59, 59), new CalFields(2011, 3, 13, 6, 59, 59), new CalFields(2011, 3, 13, 7, 0, 0) }, { "America/New_York", new CalFields(2011, 3, 13, 3, 0, 0), true, new CalFields(2011, 3, 13, 7, 0, 0), new CalFields(2011, 3, 13, 7, 0, 0), new CalFields(2011, 3, 13, 7, 0, 0) }, { "Pacific/Apia", new CalFields(2011, 12, 29, 23, 59, 59), true, new CalFields(2011, 12, 30, 9, 59, 59), new CalFields(2011, 12, 30, 9, 59, 59), new CalFields(2011, 12, 30, 9, 59, 59) }, { "Pacific/Apia", new CalFields(2011, 12, 30, 0, 0, 0), false, new CalFields(2011, 12, 30, 10, 0, 0), new CalFields(2011, 12, 29, 10, 0, 0), new CalFields(2011, 12, 30, 10, 0, 0) }, { "Pacific/Apia", new CalFields(2011, 12, 30, 12, 0, 0), false, new CalFields(2011, 12, 30, 22, 0, 0), new CalFields(2011, 12, 29, 22, 0, 0), new CalFields(2011, 12, 30, 10, 0, 0) }, { "Pacific/Apia", new CalFields(2011, 12, 30, 23, 59, 59), false, new CalFields(2011, 12, 31, 9, 59, 59), new CalFields(2011, 12, 30, 9, 59, 59), new CalFields(2011, 12, 30, 10, 0, 0) }, { "Pacific/Apia", new CalFields(2011, 12, 31, 0, 0, 0), true, new CalFields(2011, 12, 30, 10, 0, 0), new CalFields(2011, 12, 30, 10, 0, 0), new CalFields(2011, 12, 30, 10, 0, 0) } };
Calendar calGMT = Calendar.getInstance(TimeZone.GMT_ZONE);
Calendar calDefault = Calendar.getInstance();
Calendar calLast = Calendar.getInstance();
Calendar calFirst = Calendar.getInstance();
Calendar calNextAvail = Calendar.getInstance();
calLast.setSkippedWallTimeOption(Calendar.WALLTIME_LAST);
calFirst.setSkippedWallTimeOption(Calendar.WALLTIME_FIRST);
calNextAvail.setSkippedWallTimeOption(Calendar.WALLTIME_NEXT_VALID);
for (Object[] test : TESTDATA) {
String tzid = (String) test[0];
TimeZone tz = TimeZone.getTimeZone(tzid);
CalFields in = (CalFields) test[1];
boolean isValid = (Boolean) test[2];
CalFields expLastGMT = (CalFields) test[3];
CalFields expFirstGMT = (CalFields) test[4];
CalFields expNextAvailGMT = (CalFields) test[5];
for (int i = 0; i < 2; i++) {
boolean bLenient = (i == 0);
// WALLTIME_LAST
calLast.setLenient(bLenient);
calLast.setTimeZone(tz);
try {
in.setTo(calLast);
calGMT.setTimeInMillis(calLast.getTimeInMillis());
CalFields outLastGMT = CalFields.createFrom(calGMT);
if (!bLenient && !isValid) {
errln("Fail: IllegalArgumentException expected - " + in + "[" + tzid + "] (WALLTIME_LAST)");
} else if (!outLastGMT.equals(expLastGMT)) {
errln("Fail: WALLTIME_LAST " + in + "[" + tzid + "] is parsed as " + outLastGMT + "[GMT]. Expected: " + expLastGMT + "[GMT]");
}
} catch (IllegalArgumentException e) {
if (bLenient || isValid) {
errln("Fail: Unexpected IllegalArgumentException - " + in + "[" + tzid + "] (WALLTIME_LAST)");
}
}
// default
calDefault.setLenient(bLenient);
calDefault.setTimeZone(tz);
try {
in.setTo(calDefault);
calGMT.setTimeInMillis(calDefault.getTimeInMillis());
CalFields outDefGMT = CalFields.createFrom(calGMT);
if (!bLenient && !isValid) {
errln("Fail: IllegalArgumentException expected - " + in + "[" + tzid + "] (default)");
} else if (!outDefGMT.equals(expLastGMT)) {
errln("Fail: (default) " + in + "[" + tzid + "] is parsed as " + outDefGMT + "[GMT]. Expected: " + expLastGMT + "[GMT]");
}
} catch (IllegalArgumentException e) {
if (bLenient || isValid) {
errln("Fail: Unexpected IllegalArgumentException - " + in + "[" + tzid + "] (default)");
}
}
// WALLTIME_FIRST
calFirst.setLenient(bLenient);
calFirst.setTimeZone(tz);
try {
in.setTo(calFirst);
calGMT.setTimeInMillis(calFirst.getTimeInMillis());
CalFields outFirstGMT = CalFields.createFrom(calGMT);
if (!bLenient && !isValid) {
errln("Fail: IllegalArgumentException expected - " + in + "[" + tzid + "] (WALLTIME_FIRST)");
} else if (!outFirstGMT.equals(expFirstGMT)) {
errln("Fail: WALLTIME_FIRST " + in + "[" + tzid + "] is parsed as " + outFirstGMT + "[GMT]. Expected: " + expFirstGMT + "[GMT]");
}
} catch (IllegalArgumentException e) {
if (bLenient || isValid) {
errln("Fail: Unexpected IllegalArgumentException - " + in + "[" + tzid + "] (WALLTIME_FIRST)");
}
}
// WALLTIME_NEXT_VALID
calNextAvail.setLenient(bLenient);
calNextAvail.setTimeZone(tz);
try {
in.setTo(calNextAvail);
calGMT.setTimeInMillis(calNextAvail.getTimeInMillis());
CalFields outNextAvailGMT = CalFields.createFrom(calGMT);
if (!bLenient && !isValid) {
errln("Fail: IllegalArgumentException expected - " + in + "[" + tzid + "] (WALLTIME_NEXT_VALID)");
} else if (!outNextAvailGMT.equals(expNextAvailGMT)) {
errln("Fail: WALLTIME_NEXT_VALID " + in + "[" + tzid + "] is parsed as " + outNextAvailGMT + "[GMT]. Expected: " + expNextAvailGMT + "[GMT]");
}
} catch (IllegalArgumentException e) {
if (bLenient || isValid) {
errln("Fail: Unexpected IllegalArgumentException - " + in + "[" + tzid + "] (WALLTIME_NEXT_VALID)");
}
}
}
}
}
use of android.icu.util.TimeZone in project j2objc by google.
the class IBMCalendarTest method TestAddRollEra0AndEraBounds.
@Test
public void TestAddRollEra0AndEraBounds() {
final String[] localeIDs = { // calendars with non-modern era 0 that goes backwards, max era == 1
"en@calendar=gregorian", "en@calendar=roc", "en@calendar=coptic", // calendars with non-modern era 0 that goes forwards, max era > 1
"en@calendar=japanese", "en@calendar=chinese", // calendars with non-modern era 0 that goes forwards, max era == 1
"en@calendar=ethiopic", // calendars with only one era = 0, forwards
"en@calendar=buddhist", "en@calendar=hebrew", "en@calendar=islamic", "en@calendar=indian", // "en@calendar=persian", // no persian calendar in ICU4J yet
"en@calendar=ethiopic-amete-alem" };
TimeZone zoneGMT = TimeZone.getFrozenTimeZone("GMT");
for (String localeID : localeIDs) {
Calendar ucalTest = Calendar.getInstance(zoneGMT, new ULocale(localeID));
String calType = ucalTest.getType();
boolean era0YearsGoBackwards = (calType.equals("gregorian") || calType.equals("roc") || calType.equals("coptic"));
int yrBefore, yrAfter, yrMax, eraAfter, eraMax, eraNow;
ucalTest.clear();
ucalTest.set(Calendar.YEAR, 2);
ucalTest.set(Calendar.ERA, 0);
yrBefore = ucalTest.get(Calendar.YEAR);
ucalTest.add(Calendar.YEAR, 1);
yrAfter = ucalTest.get(Calendar.YEAR);
if ((era0YearsGoBackwards && yrAfter > yrBefore) || (!era0YearsGoBackwards && yrAfter < yrBefore)) {
errln("Fail: era 0 add 1 year does not move forward in time for " + localeID);
}
ucalTest.clear();
ucalTest.set(Calendar.YEAR, 2);
ucalTest.set(Calendar.ERA, 0);
yrBefore = ucalTest.get(Calendar.YEAR);
ucalTest.roll(Calendar.YEAR, 1);
yrAfter = ucalTest.get(Calendar.YEAR);
if ((era0YearsGoBackwards && yrAfter > yrBefore) || (!era0YearsGoBackwards && yrAfter < yrBefore)) {
errln("Fail: era 0 roll 1 year does not move forward in time for " + localeID);
}
ucalTest.clear();
ucalTest.set(Calendar.YEAR, 1);
ucalTest.set(Calendar.ERA, 0);
if (era0YearsGoBackwards) {
ucalTest.roll(Calendar.YEAR, 1);
yrAfter = ucalTest.get(Calendar.YEAR);
eraAfter = ucalTest.get(Calendar.ERA);
if (eraAfter != 0 || yrAfter != 1) {
errln("Fail: era 0 roll 1 year from year 1 does not stay within era or pin to year 1 for " + localeID + " (get era " + eraAfter + " year " + yrAfter + ")");
}
} else {
// roll backward in time to where era 0 years go negative, except for the Chinese
// calendar, which uses negative eras instead of having years outside the range 1-60
ucalTest.roll(Calendar.YEAR, -2);
yrAfter = ucalTest.get(Calendar.YEAR);
eraAfter = ucalTest.get(Calendar.ERA);
if (!calType.equals("chinese") && (eraAfter != 0 || yrAfter != -1)) {
errln("Fail: era 0 roll -2 years from year 1 does not stay within era or produce year -1 for " + localeID + " (get era " + eraAfter + " year " + yrAfter + ")");
}
}
ucalTest.clear();
{
int eraMin = ucalTest.getMinimum(Calendar.ERA);
if (eraMin != 0 && calType.compareTo("chinese") != 0) {
errln("Fail: getMinimum returns minimum era " + eraMin + " (should be 0) for calType " + calType);
}
}
ucalTest.clear();
ucalTest.set(Calendar.YEAR, 1);
ucalTest.set(Calendar.ERA, 0);
eraMax = ucalTest.getMaximum(Calendar.ERA);
if (eraMax > 0) {
// try similar tests for era 1 (if calendar has it), in which years always go forward
ucalTest.clear();
ucalTest.set(Calendar.YEAR, 2);
ucalTest.set(Calendar.ERA, 1);
yrBefore = ucalTest.get(Calendar.YEAR);
ucalTest.add(Calendar.YEAR, 1);
yrAfter = ucalTest.get(Calendar.YEAR);
if (yrAfter < yrBefore) {
errln("Fail: era 1 add 1 year does not move forward in time for " + localeID);
}
ucalTest.clear();
ucalTest.set(Calendar.YEAR, 2);
ucalTest.set(Calendar.ERA, 1);
yrBefore = ucalTest.get(Calendar.YEAR);
ucalTest.roll(Calendar.YEAR, 1);
yrAfter = ucalTest.get(Calendar.YEAR);
if (yrAfter < yrBefore) {
errln("Fail: era 1 roll 1 year does not move forward in time for " + localeID);
}
ucalTest.clear();
ucalTest.set(Calendar.YEAR, 1);
ucalTest.set(Calendar.ERA, 1);
yrMax = ucalTest.getActualMaximum(Calendar.YEAR);
// roll down which should pin or wrap to end
ucalTest.roll(Calendar.YEAR, -1);
yrAfter = ucalTest.get(Calendar.YEAR);
eraAfter = ucalTest.get(Calendar.ERA);
// if yrMax is reasonable we should wrap to that, else we should pin at yr 1
if (yrMax >= 32768) {
if (eraAfter != 1 || yrAfter != 1) {
errln("Fail: era 1 roll -1 year from year 1 does not stay within era or pin to year 1 for " + localeID + " (get era " + eraAfter + " year " + yrAfter + ")");
}
} else if (eraAfter != 1 || yrAfter != yrMax) {
errln("Fail: era 1 roll -1 year from year 1 does not stay within era or wrap to year " + yrMax + " for " + localeID + " (get era " + eraAfter + " year " + yrAfter + ")");
} else {
// now roll up which should wrap to beginning
ucalTest.roll(Calendar.YEAR, 1);
yrAfter = ucalTest.get(Calendar.YEAR);
eraAfter = ucalTest.get(Calendar.ERA);
if (eraAfter != 1 || yrAfter != 1) {
errln("Fail: era 1 roll 1 year from year " + yrMax + " does not stay within era or wrap to year 1 for " + localeID + " (get era " + eraAfter + " year " + yrAfter + ")");
}
}
// if current era > 1, try the same roll tests for current era
ucalTest.setTime(new Date());
eraNow = ucalTest.get(Calendar.ERA);
if (eraNow > 1) {
ucalTest.clear();
ucalTest.set(Calendar.YEAR, 1);
ucalTest.set(Calendar.ERA, eraNow);
// max year value for this era
yrMax = ucalTest.getActualMaximum(Calendar.YEAR);
ucalTest.roll(Calendar.YEAR, -1);
yrAfter = ucalTest.get(Calendar.YEAR);
eraAfter = ucalTest.get(Calendar.ERA);
// if yrMax is reasonable we should wrap to that, else we should pin at yr 1
if (yrMax >= 32768) {
if (eraAfter != eraNow || yrAfter != 1) {
errln("Fail: era " + eraNow + " roll -1 year from year 1 does not stay within era or pin to year 1 for " + localeID + " (get era " + eraAfter + " year " + yrAfter + ")");
}
} else if (eraAfter != eraNow || yrAfter != yrMax) {
errln("Fail: era " + eraNow + " roll -1 year from year 1 does not stay within era or wrap to year " + yrMax + " for " + localeID + " (get era " + eraAfter + " year " + yrAfter + ")");
} else {
// now roll up which should wrap to beginning
ucalTest.roll(Calendar.YEAR, 1);
yrAfter = ucalTest.get(Calendar.YEAR);
eraAfter = ucalTest.get(Calendar.ERA);
if (eraAfter != eraNow || yrAfter != 1) {
errln("Fail: era " + eraNow + " roll 1 year from year " + yrMax + " does not stay within era or wrap to year 1 for " + localeID + " (get era " + eraAfter + " year " + yrAfter + ")");
}
}
}
}
}
}
use of android.icu.util.TimeZone in project j2objc by google.
the class IBMCalendarTest method TestRepeatedWallTime.
@Test
public void TestRepeatedWallTime() {
final Object[][] TESTDATA = { // Time zone Input wall time WALLTIME_LAST in GMT WALLTIME_FIRST in GMT
{ "America/New_York", new CalFields(2011, 11, 6, 0, 59, 59), new CalFields(2011, 11, 6, 4, 59, 59), new CalFields(2011, 11, 6, 4, 59, 59) }, { "America/New_York", new CalFields(2011, 11, 6, 1, 0, 0), new CalFields(2011, 11, 6, 6, 0, 0), new CalFields(2011, 11, 6, 5, 0, 0) }, { "America/New_York", new CalFields(2011, 11, 6, 1, 0, 1), new CalFields(2011, 11, 6, 6, 0, 1), new CalFields(2011, 11, 6, 5, 0, 1) }, { "America/New_York", new CalFields(2011, 11, 6, 1, 30, 0), new CalFields(2011, 11, 6, 6, 30, 0), new CalFields(2011, 11, 6, 5, 30, 0) }, { "America/New_York", new CalFields(2011, 11, 6, 1, 59, 59), new CalFields(2011, 11, 6, 6, 59, 59), new CalFields(2011, 11, 6, 5, 59, 59) }, { "America/New_York", new CalFields(2011, 11, 6, 2, 0, 0), new CalFields(2011, 11, 6, 7, 0, 0), new CalFields(2011, 11, 6, 7, 0, 0) }, { "America/New_York", new CalFields(2011, 11, 6, 2, 0, 1), new CalFields(2011, 11, 6, 7, 0, 1), new CalFields(2011, 11, 6, 7, 0, 1) }, { "Australia/Lord_Howe", new CalFields(2011, 4, 3, 1, 29, 59), new CalFields(2011, 4, 2, 14, 29, 59), new CalFields(2011, 4, 2, 14, 29, 59) }, { "Australia/Lord_Howe", new CalFields(2011, 4, 3, 1, 30, 0), new CalFields(2011, 4, 2, 15, 0, 0), new CalFields(2011, 4, 2, 14, 30, 0) }, { "Australia/Lord_Howe", new CalFields(2011, 4, 3, 1, 45, 0), new CalFields(2011, 4, 2, 15, 15, 0), new CalFields(2011, 4, 2, 14, 45, 0) }, { "Australia/Lord_Howe", new CalFields(2011, 4, 3, 1, 59, 59), new CalFields(2011, 4, 2, 15, 29, 59), new CalFields(2011, 4, 2, 14, 59, 59) }, { "Australia/Lord_Howe", new CalFields(2011, 4, 3, 2, 0, 0), new CalFields(2011, 4, 2, 15, 30, 0), new CalFields(2011, 4, 2, 15, 30, 0) }, { "Australia/Lord_Howe", new CalFields(2011, 4, 3, 2, 0, 1), new CalFields(2011, 4, 2, 15, 30, 1), new CalFields(2011, 4, 2, 15, 30, 1) } };
Calendar calGMT = Calendar.getInstance(TimeZone.GMT_ZONE);
Calendar calDefault = Calendar.getInstance();
Calendar calLast = Calendar.getInstance();
Calendar calFirst = Calendar.getInstance();
calFirst.setRepeatedWallTimeOption(Calendar.WALLTIME_FIRST);
calLast.setRepeatedWallTimeOption(Calendar.WALLTIME_LAST);
for (Object[] test : TESTDATA) {
String tzid = (String) test[0];
TimeZone tz = TimeZone.getTimeZone(tzid);
CalFields in = (CalFields) test[1];
CalFields expLastGMT = (CalFields) test[2];
CalFields expFirstGMT = (CalFields) test[3];
// WALLTIME_LAST
calLast.setTimeZone(tz);
in.setTo(calLast);
calGMT.setTimeInMillis(calLast.getTimeInMillis());
CalFields outLastGMT = CalFields.createFrom(calGMT);
if (!outLastGMT.equals(expLastGMT)) {
errln("Fail: WALLTIME_LAST " + in + "[" + tzid + "] is parsed as " + outLastGMT + "[GMT]. Expected: " + expLastGMT + "[GMT]");
}
// default
calDefault.setTimeZone(tz);
in.setTo(calDefault);
calGMT.setTimeInMillis(calDefault.getTimeInMillis());
CalFields outDefGMT = CalFields.createFrom(calGMT);
if (!outDefGMT.equals(expLastGMT)) {
errln("Fail: (default) " + in + "[" + tzid + "] is parsed as " + outDefGMT + "[GMT]. Expected: " + expLastGMT + "[GMT]");
}
// WALLTIME_FIRST
calFirst.setTimeZone(tz);
in.setTo(calFirst);
calGMT.setTimeInMillis(calFirst.getTimeInMillis());
CalFields outFirstGMT = CalFields.createFrom(calGMT);
if (!outFirstGMT.equals(expFirstGMT)) {
errln("Fail: WALLTIME_FIRST " + in + "[" + tzid + "] is parsed as " + outFirstGMT + "[GMT]. Expected: " + expFirstGMT + "[GMT]");
}
}
}
use of android.icu.util.TimeZone in project j2objc by google.
the class CalendarRegressionTest method Test4031502.
/*
Synopsis: java.sql.Timestamp constructor works wrong on Windows 95
==== Here is the test ====
public static void main (String args[]) {
java.sql.Timestamp t= new java.sql.Timestamp(0,15,5,5,8,13,123456700);
logln("expected=1901-04-05 05:08:13.1234567");
logln(" result="+t);
}
==== Here is the output of the test on Solaris or NT ====
expected=1901-04-05 05:08:13.1234567
result=1901-04-05 05:08:13.1234567
==== Here is the output of the test on Windows95 ====
expected=1901-04-05 05:08:13.1234567
result=1901-04-05 06:08:13.1234567
*/
@Test
public void Test4031502() {
try {
// This bug actually occurs on Windows NT as well, and doesn't
// require the host zone to be set; it can be set in Java.
String[] ids = TimeZone.getAvailableIDs();
boolean bad = false;
for (int i = 0; i < ids.length; ++i) {
TimeZone zone = TimeZone.getTimeZone(ids[i]);
GregorianCalendar cal = new GregorianCalendar(zone);
cal.clear();
cal.set(1900, 15, 5, 5, 8, 13);
if (cal.get(Calendar.HOUR) != 5) {
logln("Fail: " + zone.getID() + " " + zone.useDaylightTime() + "; DST_OFFSET = " + cal.get(Calendar.DST_OFFSET) / (60 * 60 * 1000.0) + "; ZONE_OFFSET = " + cal.get(Calendar.ZONE_OFFSET) / (60 * 60 * 1000.0) + "; getRawOffset() = " + zone.getRawOffset() / (60 * 60 * 1000.0) + "; HOUR = " + cal.get(Calendar.HOUR));
cal.clear();
cal.set(1900, 15, 5, 5, 8, 13);
if (cal.get(Calendar.HOUR) != 5) {
logln("Fail: " + zone.getID() + " " + zone.useDaylightTime() + "; DST_OFFSET = " + cal.get(Calendar.DST_OFFSET) / (60 * 60 * 1000.0) + "; ZONE_OFFSET = " + cal.get(Calendar.ZONE_OFFSET) / (60 * 60 * 1000.0) + "; getRawOffset() = " + zone.getRawOffset() / (60 * 60 * 1000.0) + "; HOUR = " + cal.get(Calendar.HOUR));
cal.clear();
cal.set(1900, 15, 5, 5, 8, 13);
logln("ms = " + cal.getTime() + " (" + cal.getTime().getTime() + ")");
cal.get(Calendar.HOUR);
java.util.GregorianCalendar cal2 = new java.util.GregorianCalendar(java.util.TimeZone.getTimeZone(ids[i]));
cal2.clear();
cal2.set(1900, 15, 5, 5, 8, 13);
cal2.get(Calendar.HOUR);
logln("java.util.GC: " + zone.getID() + " " + zone.useDaylightTime() + "; DST_OFFSET = " + cal2.get(Calendar.DST_OFFSET) / (60 * 60 * 1000.0) + "; ZONE_OFFSET = " + cal2.get(Calendar.ZONE_OFFSET) / (60 * 60 * 1000.0) + "; getRawOffset() = " + zone.getRawOffset() / (60 * 60 * 1000.0) + "; HOUR = " + cal.get(Calendar.HOUR));
logln("ms = " + cal2.getTime() + " (" + cal2.getTime().getTime() + ")");
bad = true;
} else if (false) {
// Change to true to debug
logln("OK: " + zone.getID() + " " + zone.useDaylightTime() + " " + cal.get(Calendar.DST_OFFSET) / (60 * 60 * 1000) + " " + zone.getRawOffset() / (60 * 60 * 1000) + ": HOUR = " + cal.get(Calendar.HOUR));
}
}
if (bad)
errln("TimeZone problems with GC");
}
} catch (MissingResourceException e) {
warnln("Could not load data. " + e.getMessage());
}
}
use of android.icu.util.TimeZone in project j2objc by google.
the class CalendarRegressionTest method Test4071385.
@Test
public void Test4071385() {
// work around bug for jdk1.4 on solaris 2.6, which uses funky timezone
// names
// jdk1.4.1 will drop support for 2.6 so we should be ok when it comes out
java.util.TimeZone javazone = java.util.TimeZone.getTimeZone("GMT");
TimeZone icuzone = TimeZone.getTimeZone("GMT");
Calendar cal = Calendar.getInstance(icuzone);
java.util.Calendar tempcal = java.util.Calendar.getInstance(javazone);
tempcal.clear();
tempcal.set(1998, Calendar.JUNE, 24);
cal.setTime(tempcal.getTime());
// change a field
cal.set(Calendar.MONTH, Calendar.NOVEMBER);
logln(cal.getTime().toString());
tempcal.set(1998, Calendar.NOVEMBER, 24);
if (!cal.getTime().equals(tempcal.getTime()))
errln("Fail");
}
Aggregations