日誌時間晚13小時

  1. 問題java

OS:CentOS6.3ide

jdk:jdk6
this

文件建立時間正常,日誌記錄時間晚於系統時間13小時日誌


2. 查看code

$ locale
LANG=en_US
LC_CTYPE="en_US"
LC_NUMERIC="en_US"
LC_TIME="en_US"
LC_COLLATE="en_US"
LC_MONETARY="en_US"
LC_MESSAGES="en_US"
LC_PAPER="en_US"
LC_NAME="en_US"
LC_ADDRESS="en_US"
LC_TELEPHONE="en_US"
LC_MEASUREMENT="en_US"
LC_IDENTIFICATION="en_US"
LC_ALL=orm


$ more /etc/sysconfig/clock
ZONE="Asia/Shanghai"
UTC=false
ARC=falseci


3. 解決rem

java啓動參數加入-Duser.timezone="Asia/Shanghai"get


4. 系統的默認user.timezoneit

When you say "defaults read from the OS & local system", there isn't a single, well-defined place to read this default from.  Even the API documentation itself says

Gets the default TimeZone for this host. The source of the default TimeZone may vary with implementation.

So the simple answer is that Joda and your JVM are inferring the default time zone from different sources of information.  The point to remember about this is that the default is a guess, not something that the JVM can definitively get access to.

For Sun's 1.5.0_06 JVM on Linux, the following order is used:

  1. Looks to environment variable TZ

  2. Looks for the file /etc/sysconfig/clock and tries to find the "ZONE" entry.

  3. Compares contents fo /etc/localtime with the contents of every file in /usr/share/zoneinfo recursively. When the contents matches, it returns the path and filename, referenced from /usr/share/zoneinfo.

Joda 1.6.2 uses:

  1. The system property user.timezone.

  2. If the above is null or not a valid identifier, the value of the JDK's TimeZone default is used.

  3. If that fails, UTC is used.

相關文章
相關標籤/搜索