United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-7044727 : (tz) TimeZone.getDefault() call returns incorrect value in Windows terminal session

Details
Type:
Bug
Submit Date:
2011-05-13
Status:
Closed
Updated Date:
2016-06-13
Project Name:
JDK
Resolved Date:
2015-04-17
Component:
core-libs
OS:
windows_2008
Sub-Component:
java.util:i18n
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:

Related Reports
Backport:
Backport:
Backport:
Backport:
Backport:
Backport:

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.6.0_23"
Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
Java HotSpot(TM) Client VM (build 19.0-b09, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Windows Server 2008 R2 Standard with SP 1
Microsoft Windows [Version 6.1.7601]

EXTRA RELEVANT SYSTEM CONFIGURATION :
Windows Server time zone is 'America/New_York'
Client time zone is 'Europe/Helsinki'

A DESCRIPTION OF THE PROBLEM :
TimeZone.getDefault() call returns server time zone ('America/New_York') instead of client's ('Europe/Helsinki') at Windows 2008 in Time Zone redirection mode for terminal sessions. This mode mean that any Remote Terminal session have own, client time zone.

Here is explanation of "Allow time zone redirection" mode in Windows
http://technet.microsoft.com/en-us/library/cc725887%28WS.10%29.aspx

I've reviewed JDK's native sources and found that problem reason is in TimeZone_md.c file at the method getWinTimeZone(...) Here Java uses registry path "System\\CurrentControlSet\\Control\\TimeZoneInformation" and string attr "TimeZoneKeyName" there for determining system TZ in modern Windows systems. But it seems this value always has server time zone even in "Allow time zone redirection" mode.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- setup "Allow time zone redirection" in Windows 2008 srv
- logon into Windows 2008 srv through Remote Desktop from different time zone
- call from console
jrunscript.exe -e "java.lang.System.out.println(java.util.TimeZone.getDefault());"

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
- see in the console server time zone while in Windows Contol Panel (or throught call tzutil /g) you'll see client's time zone
ACTUAL -
C:\tmp>C:\tools\Java\jdk1.6.0_u23\bin\jrunscript.exe -e "java.lang.System.out.println(java.util.TimeZone.getDefault());"
sun.util.calendar.ZoneInfo[id="America/New_York",offset=-18000000,dstSavings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleTimeZone[id=America/New_Y
ork,offset=-18000000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,en
dMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]]

C:\tmp>tzutil /g
FLE Standard Time

REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
Use -D param 'user.timezone' for mandatory time zone set for JVM. Unfortunately, our clients may logon into Windows server from different time zones and this workaround isn't an option for us.

                                    

Comments
URL:   http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/ff7cdc646abd
User:  lana
Date:  2015-04-23 01:41:22 +0000

                                     
2015-04-23
URL:   http://hg.openjdk.java.net/jdk9/dev/jdk/rev/ff7cdc646abd
User:  okutsu
Date:  2015-04-17 07:50:48 +0000

                                     
2015-04-17
A regression test requires Windows terminal session setup. So, no regression tests are provided with the fix.
                                     
2015-04-07



Hardware and Software, Engineered to Work Together