Java Time Zone is messed up

前端 未结 4 1536
悲哀的现实
悲哀的现实 2020-11-28 06:52

I am running a Tomcat application, and I need to display some time values. Unfortunately, the time is coming up an hour off. I looked into it and discovered that my defaul

4条回答
  •  死守一世寂寞
    2020-11-28 07:12

    On Ubuntu, it's not enough to just change the /etc/localtime file. It seems to read /etc/timezone file, too. It's better follow the instruction to set the time zone properly. In particular, do the following:

    $ sudo cp /etc/timezone /etc/timezone.dist
    $ echo "Australia/Adelaide" | sudo tee /etc/timezone
    Australia/Adelaide
    $ sudo dpkg-reconfigure --frontend noninteractive tzdata
    
    Current default time zone: 'Australia/Adelaide'
    Local time is now:      Sat May  8 21:19:24 CST 2010.
    Universal Time is now:  Sat May  8 11:49:24 UTC 2010.
    

    On my Ubuntu, if /etc/localtime and /etc/timezone are inconsistent, Java seems to read default time zone from /etc/timezone .

提交回复
热议问题