Jvm time zone settings in Linux

Source: Internet
Author: User
Linux jvm time zone settings-general Linux technology-Linux programming and kernel information. For more information, see the following. On a streamlined Linux installation, jre finds that the time obtained by all java programs is not the system time. Later, it was found that the time zone was incorrect. The time obtained by the java program is GMT, while the system is Beijing time, which should be GMT + 8, with a difference of 8 hours. There are only two ways to search for a lot of information on the Internet:

1. Set the time zone using java functions in the program.

2. Add the parameter-Duser. timezone = GMT + 8 when starting the java program.

However, you cannot modify the source code of each program to set the time zone. It is too troublesome to add parameters when every java program starts. There is no way to do it once and for all?

At first, I thought that jre should have a configuration file that stores the time zone configuration. The result was nothing. However, there is always a jre that will always go to the system to get the time zone configuration. So I started to wonder if java uses the linux system configuration file? In linux, you can view the time zone configuration in the/etc/sysconfig directory. The clock file used to set the time zone is missing. Copy this file from another linux system and try again. OK. The java program time is the same as the system time. It seems that jre obtains the time zone information from the/etc/sysconfig/clock file.

Content of the clock file:

ZONE = "Asia/Shanghai"
UTC = false
ARC = false

ZONE -- Time ZONE
UTC -- indicates that the clock is set to UTC.
ARC -- used for alpha only to indicate that ARC is used.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.