问题
OS:CentOS6.3
jdk:jdk6
文件创建时间正常,日志记录时间晚于系统时间13小时
2. 查看
$ 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=
$ more /etc/sysconfig/clock
ZONE="Asia/Shanghai"
UTC=false
ARC=false
3. 解决
java启动参数加入-Duser.timezone="Asia/Shanghai"
4. 系统的默认user.timezone
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 defaultTimeZone
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:
Looks to environment variable TZ
Looks for the file /etc/sysconfig/clock and tries to find the "ZONE" entry.
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:
The system property user.timezone
.
If the above is null
or not a valid identifier, the value of the JDK‘s TimeZone
default is used.
If that fails, UTC
is used.
本文出自 “Ying:好记性不如烂笔头” 博客,请务必保留此出处http://yingtju.blog.51cto.com/3760152/1429180
原文地址:http://yingtju.blog.51cto.com/3760152/1429180