TimeZone.setDefault changes in JDK6

后端 未结 3 549
不知归路
不知归路 2020-12-06 00:44

I just noticed that JDK 6 has a different approach to setting a default TimeZone than JDK5.

Previously the new default would be stored in a thread-local variable. W

相关标签:
3条回答
  • 2020-12-06 01:18

    This was probably done to fix a bug. I'd search bugs.sun.com to find the rationale for it. (Clues might also be found in the release notes.)

    0 讨论(0)
  • 2020-12-06 01:25

    The API documentation for TimeZone.getDefault() states that "the source of the default TimeZone may vary with implementation." If your code relies on implementation specific behaviour of the standard API classes (in this case, that the default time zone is kept at a thread local level), you must expect that your code fails with newer versions of the VM or with VMs from different vendors.

    0 讨论(0)
  • 2020-12-06 01:35

    Searching the bugs database was actually quite a good idea :)

    http://bugs.sun.com/view_bug.do?bug_id=6352812

    and also (re docs):

    http://bugs.sun.com/view_bug.do?bug_id=6181786

    Summary: JDK 1.5 was an exception to the rule, with JDK 1.6 things are back to 'normal', which, according to the docs, is that a timezone change is VM wide.

    0 讨论(0)
提交回复
热议问题