ICU-5056 fix crashing bug in getDefault implementation

X-SVN-Rev: 19153
This commit is contained in:
Ram Viswanadha 2006-02-13 23:43:19 +00:00
parent ba21b7880e
commit 51056b601b
2 changed files with 18 additions and 3 deletions

View File

@ -1,6 +1,6 @@
/** /**
******************************************************************************* *******************************************************************************
* Copyright (C) 2000-2005, International Business Machines Corporation and * * Copyright (C) 2000-2006, International Business Machines Corporation and *
* others. All Rights Reserved. * * others. All Rights Reserved. *
******************************************************************************* *******************************************************************************
*/ */
@ -1178,7 +1178,22 @@ public class TimeZoneTest extends TestFmwk
if(!list.contains(tzid)){ if(!list.contains(tzid)){
errln("Could create the time zone but it is not in getAvailableIDs"); errln("Could create the time zone but it is not in getAvailableIDs");
} }
}
public void TestZoneMeta() {
java.util.TimeZone save = java.util.TimeZone.getDefault();
java.util.TimeZone newZone = java.util.TimeZone.getTimeZone("GMT-08:00");
com.ibm.icu.util.TimeZone.setDefault(null);
java.util.TimeZone.setDefault(newZone);
SimpleTimeZone zone = new SimpleTimeZone(0, "GMT");
com.ibm.icu.util.TimeZone defaultZone = com.ibm.icu.util.TimeZone.getDefault();
if(defaultZone==null){
errln("TimeZone.getDefault() failed for GMT-08:00");
}
if(zone==null){
errln("SimpleTimeZone(0, GMT-08:00) failed for GMT-08:00");
}
//reset
java.util.TimeZone.setDefault(save);
} }
} }

View File

@ -695,7 +695,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
public static synchronized TimeZone getDefault() { public static synchronized TimeZone getDefault() {
if (defaultZone == null) { if (defaultZone == null) {
java.util.TimeZone temp=java.util.TimeZone.getDefault(); java.util.TimeZone temp=java.util.TimeZone.getDefault();
defaultZone = ZoneMeta.getSystemTimeZone(temp.getID()); defaultZone = getTimeZone(temp.getID());
} }
return (TimeZone) defaultZone.clone(); return (TimeZone) defaultZone.clone();
} }