Joda time zone differs from JDK

In my client, I have this code:

System.out.println("Java tz: " + TimeZone.getDefault());
System.out.println("Joda tz: " + ISOChronology.getInstance());

These two lines work one after another. I have never set the time zone or user.timezonemanually, just rely on the default values ​​read from the OS and local system.

When executed, they produce:

Java tz: sun.util.calendar.ZoneInfo[id="UTC",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null]
Joda tz: ISOChronology[America/Phoenix]

The system time zone is really Phoenix, not UTC. How can Joda be right and the JDK is wrong?

EDIT . This is the host for Windows 7 x64, JRE - 1.6.22 x64.

EDIT 2 . Do not try to play it. This happens only in some, but not in all systems (for example, several dozen in the 3k database). I already know that Joda checks user.timezone, and then TimeZone.getDefault(). Therefore, I am looking for an explanation of how it could be otherwise when I call TimeZonedirectly, and Yoda does it himself.

+3
source share
1 answer

When you say "default values ​​read from the OS and the local system," there is not a single, well-defined place to read this default value. Even the API documentation itself says

Gets the default TimeZonefor this host. The default source TimeZonemay vary depending on the implementation.

, , Joda JVM . , - , , JVM .

Sun 1.5.0_06 JVM Linux :

  • TZ
  • /etc/sysconfig/clock "ZONE".
  • fo/etc/localtime /usr/share/zoneinfo . , , /usr/share/zoneinfo.

Joda 1.6.2 :

  • user.timezone.
  • null , JDK TimeZone .
  • , UTC.

, JDK Joda, , user.timezone . .

: Sun JDK 1.6.0_22 user.timezone, , user.country, , , GMT. , , , JVM.


2: ( , ), ! Joda, , java.util.TimeZone.getDefault() , . JDK , .

JDK, , . , - - TimeZone.setDefault(), , , . , , .

+7

All Articles