From e4a391e7fa1fb4d9be721c1e8964b67e66d4b247 Mon Sep 17 00:00:00 2001 From: Ram Viswanadha Date: Fri, 28 Oct 2005 00:00:54 +0000 Subject: [PATCH] ICU-4874 fix serialization problems X-SVN-Rev: 18725 --- .../icu/dev/test/timezone/TimeZoneRegression.java | 12 +++++++----- .../ibm/icu/dev/test/timezone/TimeZoneTest.java | 14 ++++++++++++++ icu4j/src/com/ibm/icu/text/SimpleDateFormat.java | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/icu4j/src/com/ibm/icu/dev/test/timezone/TimeZoneRegression.java b/icu4j/src/com/ibm/icu/dev/test/timezone/TimeZoneRegression.java index f7777d6fa2a..4f565b274c6 100755 --- a/icu4j/src/com/ibm/icu/dev/test/timezone/TimeZoneRegression.java +++ b/icu4j/src/com/ibm/icu/dev/test/timezone/TimeZoneRegression.java @@ -685,7 +685,7 @@ public class TimeZoneRegression extends TestFmwk { SimpleDateFormat fmt = new SimpleDateFormat("z", Locale.US); final int ONE_HOUR = 60*60*1000; final float H = (float) ONE_HOUR; - TimeZone initialZone = TimeZone.getDefault(); + TimeZone initialZone = TimeZone.getDefault(); SimpleDateFormat sdf = new SimpleDateFormat("MMM dd yyyy HH:mm z"); SimpleTimeZone asuncion = new SimpleTimeZone(-4*ONE_HOUR, "America/Asuncion" /*PY%sT*/, @@ -871,6 +871,9 @@ public class TimeZoneRegression extends TestFmwk { /** * SimpleTimeZone allows invalid DOM values. */ + // Current orgnaization of data in zoneinfor.res allows negative + // values from DOM so comment these tests out + public void Test4184229() { SimpleTimeZone zone = null; try { @@ -898,10 +901,9 @@ public class TimeZoneRegression extends TestFmwk { logln("(d) " + e.getMessage()); } // Make a valid constructor call for subsequent tests. + zone = new SimpleTimeZone(0, "A", 0, 1, 0, 0, 0, 1, 0, 0); - // Current orgnaization of data in zoneinfor.res allows negative - // values fro DOM so comment these tests out - /* + try { zone.setStartRule(0, -1, 0, 0); errln("Failed. No exception has been thrown for DOM -1 setStartRule +savings"); @@ -926,7 +928,7 @@ public class TimeZoneRegression extends TestFmwk { } catch(IllegalArgumentException e) { logln("(h) " + e.getMessage()); } - */ + } /** diff --git a/icu4j/src/com/ibm/icu/dev/test/timezone/TimeZoneTest.java b/icu4j/src/com/ibm/icu/dev/test/timezone/TimeZoneTest.java index eb2b97a4e0e..ef761d639f9 100755 --- a/icu4j/src/com/ibm/icu/dev/test/timezone/TimeZoneTest.java +++ b/icu4j/src/com/ibm/icu/dev/test/timezone/TimeZoneTest.java @@ -24,8 +24,10 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; import java.util.Date; import java.util.Hashtable; +import java.util.List; import java.util.Locale; public class TimeZoneTest extends TestFmwk @@ -1133,8 +1135,20 @@ public class TimeZoneTest extends TestFmwk } if (!stub.hasSameRules(stub2)){ errln("TimeZone.clone() object should hasSameRules"); + } } + public void TestMark(){ + String tzid = "America/Argentina/ComodRivadavia"; + TimeZone tz = TimeZone.getTimeZone(tzid); + int offset = tz.getOffset(new Date().getTime()); + logln(tzid + ":\t" + offset); + List list = Arrays.asList(TimeZone.getAvailableIDs()); + if(!list.contains(tzid)){ + errln("Could create the time zone but it is not in getAvailableIDs"); + } + + } } //eof diff --git a/icu4j/src/com/ibm/icu/text/SimpleDateFormat.java b/icu4j/src/com/ibm/icu/text/SimpleDateFormat.java index e3ad5bfa335..5456321cd09 100755 --- a/icu4j/src/com/ibm/icu/text/SimpleDateFormat.java +++ b/icu4j/src/com/ibm/icu/text/SimpleDateFormat.java @@ -847,7 +847,7 @@ public class SimpleDateFormat extends DateFormat { // note, tr35 does not describe the special case for 'no country' // implemented below, this is from discussion with Mark if (zid == null || !isGeneric || ZoneMeta.getCanonicalCountry(zid) == null) { - long offset = cal.get(Calendar.ZONE_OFFSET) + + long offset = cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET); res = ZoneMeta.displayGMT(offset, locale); } else {