JDK-6390869 : TimeZone.getDefault() returns different timezones for Windows GMT-12 when DST is checked and not.
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 1.4.0,5.0u6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_2000,windows_xp
  • CPU: x86
  • Submitted: 2006-02-27
  • Updated: 2010-09-29
  • Resolved: 2006-03-14
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 JDK 6
5.0u8Fixed 6 b76Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
Hardware: Pentium IV
OS: Windows XP Professional SP2
Java version: java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)

Problem: TimeZone.getDefault() returns two different timezones for Windows GMT-12 regarding to the 'Automatically adjust clock for daylight saving changes' is checked and not. When the daylight saving adjustment checkbox is off, java correctly recogizes GMT-12 as "GMT-12:00". But when it's checked on, Pacific/Majuro is returned, whose timezone is GMT+12.

Test case: A simple program is provided to re-produce the problem. It can be re-produced always.
//////////////////////////////////////////////////////////////
// TestTimeZone.java - BEGIN                                //
//////////////////////////////////////////////////////////////
import java.util.*;

public class TestTimeZone
{
  public static void main(String[] args)
  {
    System.out.println("timezone is " + TimeZone.getDefault());
    System.out.println("time is " + new Date());
  }
}
//////////////////////////////////////////////////////////////
// TestTimeZone.java - END                                  //
//////////////////////////////////////////////////////////////

Steps to re-produce:
1. Compile the above program.
2. Select Windows XP timezone as (GMT+10:00) Canberra, Melbourne, Sydney.
3. Un-check the 'Automatically adjust clock for daylight saving changes' checkbox.
4. Change the timezone to (GMT-12:00) International Dateline West.
5. Run the test program. It should give you a similar output like below. It's correct.

=========== step 5 output begin ===============
timezone is sun.util.calendar.ZoneInfo[id="GMT-12:00",offset=-43200000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null]
time is Sun Feb 26 18:39:02 GMT-12:00 2006
=========== step 5 output end ==================

6. Select Windows XP timezone again as (GMT+10:00) Canberra, Melbourne, Sydney.
7. Check on the 'Automatically adjust clock for daylight saving changes'.
8. Change the timezone to (GMT-12:00) International Dateline West.
9. Run the test program again. It'll give you a similar output like below. It's incorrect.

=========== step 9 output begin ===============
timezone is sun.util.calendar.ZoneInfo[id="Pacific/Majuro",offset=43200000,dstSavings=0,useDaylight=false,transitions=4,lastRule=null]
time is Mon Feb 27 18:37:53 MHT 2006
=========== step 9 output end ==================

Notice that, Pacific/Majuro is a timezone of GMT+12. So the application gets 24-hours time difference as the DST is on and not for GMT-12 on Windows.

Comments
EVALUATION The Pacific/Majuro mapping isn't correct. There's no time zone which is in GMT-12. "GMT-12:00" should be used in the mapping table.
27-02-2006