java - JVM has incorrect timezone after installation of jdk 8 -
i have tomcat service on centos server, , time sensitive service. jvm has gotten timezone correctly until installed jdk 8 yesterday.
to fix have add "-duser.timezone=gmt+8" after java command, feel inconvenient.
i use date
command on server , gives correct timezone. curious: 1. cause problem 2. , how solve neatly?
thank in advance.
here comes test info:
[chiming1@localhost test]$ date +'%y%m%d %h:%m:%s %z' 20170920 15:01:20 +0800 [chiming1@localhost test]$ java -duser.timezone=gmt+08 javatest/test 2017-09-20 15:01:34 gmt+08:00 gmt+08:00 [chiming1@localhost test]$ java javatest/test 2017-09-20 07:01:48 greenwich mean time gmt [chiming1@localhost test]$ java -version java version "1.8.0_144" java(tm) se runtime environment (build 1.8.0_144-b01) java hotspot(tm) 64-bit server vm (build 25.144-b01, mixed mode)
and java test code is:
simpledateformat sdf = new simpledateformat("yyyy-mm-dd hh:mm:ss"); date d = new date(); system.out.println(sdf.format(d)); timezone tz = timezone.getdefault(); system.out.println(tz.getdisplayname()); system.out.println(tz.getid());
can post example of output? if in format of 2016-07-11t11:01:25.498z
in utc time (if ends in z utc).
you can use system.setproperty("user.timezone", "gmt+8");
or add environment variable defaults "gmt+8"
Comments
Post a Comment