-
Bug
-
Resolution: Fixed
-
P4
-
1.2.0
-
beta
-
sparc
-
solaris_2.5
Name: avC70361 Date: 09/28/98
The java.util.TimeZone.getDisplayName(boolean, int, Locale) returns wrong result for SimpleTimeZone
instances with DSTSavings not equal to 1 hour. When a time zone's display name is not available for the localeand the first parameter is true(returns daylight savings name) it returns a result considering DST offset
always to be 1 hour whereas the right value can be different.
Here is a test demonstrating the bug.
--------------GetDisplayNameTest.java---------------
import java.util.Locale;
import java.util.SimpleTimeZone;
import java.util.TimeZone;
public class GetDisplayNameTest {
public static void main(String args[]) {
int offset = 3 * 60 * 60 * 1000 / 2; // 1.5 hour
SimpleTimeZone stz = new SimpleTimeZone(offset, "My TZ");
stz.setDSTSavings(60 * 60 * 1000 / 2); // DST offset 0.5 hour
String name = stz.getDisplayName(true, TimeZone.SHORT, Locale.getDefault());
String expected = "GMT+02:00"; // offset during DST 1.5 + 0.5 = 2 hour
if (name.equals(expected)) {
System.out.println("Passed");
} else {
System.out.println(
"Failed. Name returned = " + name + ", expected name = " + expected
);
}
}
}
-------------The test output----------
> java GetDisplayNameTest
Failed. Name returned = GMT+02:30, expected name = GMT+02:00
======================================================================
- relates to
-
JDK-6513198 java/util/TimeZone/TimeZoneRegression.java test failed against 1.2.2_14 on Solaris 8 sun4u
- Closed