JDK-4035146 : All dates display as PST regardless of TimeZone
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util
  • Affected Version: 1.1,1.1.5
  • Priority: P1
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_95,windows_nt
  • CPU: x86
  • Submitted: 1997-02-27
  • Updated: 1997-10-23
  • Resolved: 1997-10-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.2.0Resolved
Related Reports
Duplicate :  
Description

Name: mc57594			Date: 02/27/97


import java.util.GregorianCalendar;
import java.util.Calendar;
import java.util.TimeZone;

// set to GMT
TimeZone thedefault = TimeZone.getTimeZone("GMT");
TimeZone.setDefault(thedefault);

// check to be sure... its GMT all right
TimeZone testdefault = TimeZone.getDefault();
String testtimezone = testdefault.getID();
System.out.println("Test timezone = " + testtimezone);

// now try to use the default GMT time zone
GregorianCalendar greenwichcalendar =
    new GregorianCalendar(1997, 3, 4, 23, 0);
// try anything to set hour to 23:00 !!!
greenwichcalendar.set(Calendar.HOUR_OF_DAY, 23);
// get time
Date greenwichdate = greenwichcalendar.getTime();
// try every format
SimpleDateFormat dateformat =
    new SimpleDateFormat("MM/dd/yy HH:mm z");
DateFormat fullformat =
    DateFormat.getDateTimeInstance(DateFormat.FULL, 
                                   DateFormat.FULL);
DateFormat longformat =
    DateFormat.getDateTimeInstance(DateFormat.LONG, 
                                   DateFormat.LONG);
DateFormat defaultformat =
    DateFormat.getDateTimeInstance(DateFormat.DEFAULT, 
                                   DateFormat.DEFAULT);
DateFormat shortformat =
    DateFormat.getDateTimeInstance(DateFormat.SHORT, 
                                   DateFormat.SHORT);
// format every way
String simplestring = dateformat.format(greenwichdate);
String fullstring = fullformat.format(greenwichdate);
String longstring = longformat.format(greenwichdate);
String defaultstring = defaultformat.format(greenwichdate);
String shortstring = shortformat.format(greenwichdate);
// all output indicates PST... why???
System.out.println("simple format: " + simplestring);
System.out.println("full format: " + fullstring);
System.out.println("long format: " + longstring);
System.out.println("default format: " + defaultstring);
System.out.println("short format: " + shortstring);

company - MCI , email - ###@###.###
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.2beta3 FIXED IN: 1.2beta3 INTEGRATED IN: 1.2beta3
14-06-2004

WORK AROUND Name: mc57594 Date: 02/27/97 ====================================================================== The workaround is to call setTimeZone(desiredTimeZone) on the DateFormat instance.
11-06-2004

EVALUATION Alan_Liu@Taligent: As designed. When you construct a SimpleDateFormat object, it uses the current default Locale's TimeZone (as defined by the DateFormatZoneData_xx class), not the default TimeZone. ====================================================== It's questionable whether that's a good design. I'd think people's expectations are more like this: If no locale is specified, the default time zone. If a locale is specified and the default time zone is in the locale (say, EST is the default time zone and the locale en_US), the default time zone. If the locale is specified and the default time zone is not in the locale (say, EST and fr_FR), the locale's default time zone. But then, there will always be exceptions. norbert.lindenberg@Eng 1997-07-16 Since this requires a better API, it can not be fixed for Sparkler. We have given a workaround to Yvonne Tso, who marked it as a driver bug in the first place. She reports that she is happy with the work around, so I am removing the 1.1.3driver keyword. brian.beck@Eng 1997-07-22
22-07-1997