United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6181786 : (tz) Documentation for TimeZone.getDefault() and TimeZone.setDefault() should clearer

Details
Type:
Enhancement
Submit Date:
2004-10-20
Status:
Open
Updated Date:
2010-07-29
Project Name:
JDK
Resolved Date:
Component:
core-libs
OS:
solaris_9
Sub-Component:
java.util:i18n
CPU:
x86
Priority:
P4
Resolution:
Unresolved
Affected Versions:
5.0
Targeted Versions:

Related Reports

Sub Tasks

Description
A DESCRIPTION OF THE PROBLEM :
TimeZone defaults are managed on a per-thread basis.  However, the documentation leads one to believe that they are managed on a per-VM basis.  The JavaDoc for these methods should be changed to reflect the reality of the implementation (or the implementation should be changed ;)

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
getDefault():
Gets the default TimeZone for this thread. The source of the default TimeZone may vary with implementation.

setDefault():
Sets the TimeZone that is returned by the getDefault method. If zone  is null, reset the default to the value it had originally when the VM first started.

Also, there is a notion of "inheritance" where a thread can call setTimeZone and threads created afterwards use this for a default - if this is intentional, it should be made explicit.
ACTUAL -
The current documentation for getDefault() reads
Gets the default TimeZone for this host. The source of the default TimeZone may vary with implementation.

And for setDefault() we have
Sets the TimeZone that is returned by the getDefault method. If zone is null, reset the default to the value it had originally when the VM first started.


URL OF FAULTY DOCUMENTATION :
http://java.sun.com/j2se/1.5.0/docs/api/java/util/TimeZone.html
###@###.### 10/20/04 10:31 GMT

                                    

Comments
EVALUATION

The submitter is correct about the inconsistency between the documentation and implementation.
###@###.### 10/23/04 02:15 GMT
                                     
2004-10-23



Hardware and Software, Engineered to Work Together