[PATCH] Fix TimeZone.getDefaultDisplayName
Jakub Jelinek
jakub@redhat.com
Sat Feb 24 16:54:00 GMT 2007
Hi!
getDefaultDisplayName from the pre-1.4 days was only calling
getDSTSavings on SimpleTimeZone. But as TimeZone itself now defines
getDSTSavings(), we can call it always (which fixes a bug when
getDefaultDisplayName is used on gnu.java.util.ZoneInfo instance).
Ok to commit?
2007-02-24 Jakub Jelinek <jakub@redhat.com>
* java/util/TimeZone.java (getDefaultDisplayName): Don't
check if TimeZone is instanceof SimpleTimeZone.
--- libjava/classpath/java/util/TimeZone.java.jj 2007-02-20 16:48:51.000000000 +0100
+++ libjava/classpath/java/util/TimeZone.java 2007-02-24 17:47:22.000000000 +0100
@@ -1402,14 +1402,7 @@ public abstract class TimeZone implement
private String getDefaultDisplayName(boolean dst)
{
- int offset = getRawOffset();
- if (dst && this instanceof SimpleTimeZone)
- {
- // ugly, but this is a design failure of the API:
- // getDisplayName takes a dst parameter even though
- // TimeZone knows nothing about daylight saving offsets.
- offset += ((SimpleTimeZone) this).getDSTSavings();
- }
+ int offset = getRawOffset() + (dst ? getDSTSavings() : 0);
StringBuffer sb = new StringBuffer(9);
sb.append("GMT");
Jakub
More information about the Java-patches
mailing list