JDK-4065240 : Setting default locale changes timezone for DateFormat
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 1.1.1,1.1.3,1.1.4,1.1.5
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,solaris_2.6,windows_95
  • CPU: generic,x86,sparc
  • Submitted: 1997-07-17
  • Updated: 1999-07-20
  • Resolved: 1999-07-20
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 Other
1.1.8 1.1.8Fixed 1.2.0Fixed
Related Reports
Duplicate :  
Duplicate :  
Description

Name: rlT66838			Date: 07/16/97


Run the following Java applet.  Notice that the
time zone for the applet is the German time
zone, not that of the virtual machine. Changing
the locale in the program to en_US changes the
timezone to PST.

I'm executing this with the 1.1.3 appletviewer.

import java.text.*;
import java.awt.*;
import java.applet.*;
import java.util.*;



// Test Java locale-sensitive date formatting on output

public class TestDateFormat extends Applet {
   Date curDate;
   DateFormat shortdate, fulldate;
   String strShortDate, strFullDate;
   public void init () {
      Locale curLocale = new Locale("de","DE");
      Locale.setDefault(curLocale);
      curDate = new Date();
      shortdate = DateFormat.getDateInstance(DateFormat.SHORT);
      fulldate = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG
);
      strShortDate = new String("The current date (short form) is " + shortdate.
format(curDate));
      strFullDate = new String("The current date (long form) is " + fulldate.for
mat(curDate));
   }

   public void paint(Graphics g) {
         g.setColor(Color.black);
         g.drawString(strShortDate,10,10);
         g.drawString(strFullDate,10,30);
   }
}

The HTML file is:
<HTML>
<HEAD>
<TITLE> Testing DateFormat </TITLE>
</HEAD>
<BODY>
This is the applet:<P>
<applet code="TestDateFormat.class" width=500 height=300>
<param name=Language value="de"> 
<param name=Territory value="DE">
</applet>
</BODY>
</HTML>

======================================================================
###@###.### - 1997-11-19 :
Related to this bug report is the following report
(Incident 20513, Bug 0129 on BetaSphere).  I tested
the code with JDK1.2beta2 (1.2U) and found that the
bug is still reproducible.  I think it should really
be fixed before JDK1.2 goes fcs next year, otherwise
international acceptance of Java is needlessly jeopardized.

SYNOPSIS : Incorrect timezone is reported when data converted by DateFormat.
DESCRIPTION : There is a bug with timezone printed in date format (Win95).
I have timezone GMT+6 but DateFormat displays time as tz = GMT+2
and allign time according to it. Date.toString() displays
correct timezone.

Sample program:

import java.text.*;
import java.util.*;

public class test_tz
{
  public static void main(String aa[])
  {
    Date date = new Date();
    System.out.println(date);
    System.out.println(DateFormat.getDateTimeInstance(DateFormat.LONG,DateFormat.LONG).format(date));
  }
}

======================================================================


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

WORK AROUND Name: rlT66838 Date: 07/16/97 None that I've found. ======================================================================
11-06-2004

EVALUATION Fixed as of 1.2b3 -alanl The bug is verified as fixed in 118h via regression testing. tao.zhang@eng 1999-03-01
01-03-1999