如何更新 Ubuntu 机器上应用程序的夏令时区

如何更新 Ubuntu 机器上应用程序的夏令时区

土耳其决定永久停留在同一时间。

夏令时于 2016 年 9 月 8 日星期四 00:00:00 结束。时钟未更改。

土耳其位于 UTC +2 和 +3 之间,因此现在将保持 +3。请参阅这里

StackOverflow 上有一个讨论但我在 Ubuntu 机器上有一个 Spring Boot 应用程序。这是我获取日期的方式:

cmntWrapper.setCreatedAtString(cmnt.getCreatedAt().
now(ZoneId.of(Constants.TURKEY_ZONE)).
format(DateTimeFormatter.ofPattern(Constants.DATE_TIME_FORMAT)));

这显示时间为 13.50,但实际上是 14.50,因为我们处于 +3。

我能做些什么?

我不想使用 UTC +3,因为他们明年可能会说,“让我们再次使用 +2-+3 来切换夏令时概念”。所以我不能冒险。

我无法在未来几周内更改代码。几周后它将保持永久不变。

您对永久性的建议是什么?

IANA 建议

java -jar tzupdater.jar options

但它不起作用:

root@vegan:/home/vegan/Downloads/tzdb# java -jar tzdata-latest.tar.gz Error: Invalid or corrupt jarfile tzdata-latest.tar.gz

这是我的 jva

root@vegan:/usr/bin# whereis java
java: /usr/bin/java /usr/share/java /usr/share/man/man1/java.1.gz

当我尝试在该目录中执行时

root@vegan:/usr/bin# java -jar tzupdater.jar -u -l http://www.iana.org/time-zones/repository/tzdata-latest.tar.gz

我收到版本错误,无法安装tz

vegan@vegan:~$ sudo apt-get update 
[sudo] password for vegan:  
Hit:1 http://tr.archive.ubuntu.com/ubuntu xenial InRelease 
Hit:2 http://tr.archive.ubuntu.com/ubuntu xenial-updates InRelease          
Hit:3 http://tr.archive.ubuntu.com/ubuntu xenial-backports InRelease  
Hit:4 http://security.ubuntu.com/ubuntu xenial-security InRelease     
Hit:5 http://ppa.launchpad.net/apandada1/brightness-controller/ubuntu
xenial InRelease Ign:6 http://ppa.launchpad.net/midori/ppa/ubuntu
xenial InRelease               Ign:7
http://dl.google.com/linux/chrome/deb stable InRelease                
Hit:8 http://ppa.launchpad.net/notepadqq-team/notepadqq/ubuntu xenial
InRelease Hit:9 http://repo.yandex.ru/yandex-browser/deb beta
InRelease                   Hit:10
http://dl.google.com/linux/chrome/deb stable Release                  
Hit:11 http://ppa.launchpad.net/webupd8team/java/ubuntu xenial
InRelease  Ign:12 http://ppa.launchpad.net/midori/ppa/ubuntu xenial
Release Hit:13 https://deb.opera.com/opera-stable stable InRelease
Ign:14 http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main amd64
Packages Hit:16 https://apt.dockerproject.org/repo ubuntu-xenial
InRelease Ign:17 http://ppa.launchpad.net/midori/ppa/ubuntu
xenial/main i386 Packages Ign:18
http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main all Packages
Ign:19 http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main
Translation-en_US Ign:20 http://ppa.launchpad.net/midori/ppa/ubuntu
xenial/main Translation-en Hit:21 https://deb.nodesource.com/node_5.x
xenial InRelease Ign:22 http://ppa.launchpad.net/midori/ppa/ubuntu
xenial/main amd64 DEP-11 Metadata Ign:23
http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main DEP-11 64x64
Icons Ign:14 http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main
amd64 Packages Ign:17 http://ppa.launchpad.net/midori/ppa/ubuntu
xenial/main i386 Packages Ign:18
http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main all Packages
Ign:19 http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main
Translation-en_US Ign:20 http://ppa.launchpad.net/midori/ppa/ubuntu
xenial/main Translation-en Ign:22
http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main amd64 DEP-11
Metadata Ign:23 http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main
DEP-11 64x64 Icons Ign:14 http://ppa.launchpad.net/midori/ppa/ubuntu
xenial/main amd64 Packages Ign:17
http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main i386 Packages
Ign:18 http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main all
Packages Ign:19 http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main
Translation-en_US Ign:20 http://ppa.launchpad.net/midori/ppa/ubuntu
xenial/main Translation-en Ign:22
http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main amd64 DEP-11
Metadata Ign:23 http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main
DEP-11 64x64 Icons Ign:14 http://ppa.launchpad.net/midori/ppa/ubuntu
xenial/main amd64 Packages Ign:17
http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main i386 Packages
Ign:18 http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main all
Packages Ign:19 http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main
Translation-en_US Ign:20 http://ppa.launchpad.net/midori/ppa/ubuntu
xenial/main Translation-en Ign:22
http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main amd64 DEP-11
Metadata Ign:23 http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main
DEP-11 64x64 Icons Ign:14 http://ppa.launchpad.net/midori/ppa/ubuntu
xenial/main amd64 Packages Ign:17
http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main i386 Packages
Ign:18 http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main all
Packages Ign:19 http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main
Translation-en_US Ign:20 http://ppa.launchpad.net/midori/ppa/ubuntu
xenial/main Translation-en Ign:22
http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main amd64 DEP-11
Metadata Ign:23 http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main
DEP-11 64x64 Icons Err:14 http://ppa.launchpad.net/midori/ppa/ubuntu
xenial/main amd64 Packages   404  Not Found Ign:17
http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main i386 Packages
Ign:18 http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main all
Packages Ign:19 http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main
Translation-en_US Ign:20 http://ppa.launchpad.net/midori/ppa/ubuntu
xenial/main Translation-en Ign:22
http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main amd64 DEP-11
Metadata Ign:23 http://ppa.launchpad.net/midori/ppa/ubuntu xenial/main
DEP-11 64x64 Icons Reading package lists... Done W: Target Packages
(main/binary-amd64/Packages) is configured multiple times in
/etc/apt/sources.list.d/yandex-browser-beta.list:3 and
/etc/apt/sources.list.d/yandex-browser.list:1 W: Target Packages
(main/binary-all/Packages) is configured multiple times in
/etc/apt/sources.list.d/yandex-browser-beta.list:3 and
/etc/apt/sources.list.d/yandex-browser.list:1 W: Target Translations
(main/i18n/Translation-en_US) is configured multiple times in
/etc/apt/sources.list.d/yandex-browser-beta.list:3 and
/etc/apt/sources.list.d/yandex-browser.list:1 W: Target Translations
(main/i18n/Translation-en) is configured multiple times in
/etc/apt/sources.list.d/yandex-browser-beta.list:3 and
/etc/apt/sources.list.d/yandex-browser.list:1 W: Target DEP-11
(main/dep11/Components-amd64.yml) is configured multiple times in
/etc/apt/sources.list.d/yandex-browser-beta.list:3 and
/etc/apt/sources.list.d/yandex-browser.list:1 W: Target DEP-11-icons
(main/dep11/icons-64x64.tar) is configured multiple times in
/etc/apt/sources.list.d/yandex-browser-beta.list:3 and
/etc/apt/sources.list.d/yandex-browser.list:1 W: The repository
'http://ppa.launchpad.net/midori/ppa/ubuntu xenial Release' does not
have a Release file. N: Data from such a repository can't be
authenticated and is therefore potentially dangerous to use. N: See
apt-secure(8) manpage for repository creation and user configuration
details. E: Failed to fetch
http://ppa.launchpad.net/midori/ppa/ubuntu/dists/xenial/main/binary-amd64/Packages
404  Not Found E: Some index files failed to download. They have been
ignored, or old ones used instead. W: Target Packages
(main/binary-amd64/Packages) is configured multiple times in
/etc/apt/sources.list.d/yandex-browser-beta.list:3 and
/etc/apt/sources.list.d/yandex-browser.list:1 W: Target Packages
(main/binary-all/Packages) is configured multiple times in
/etc/apt/sources.list.d/yandex-browser-beta.list:3 and
/etc/apt/sources.list.d/yandex-browser.list:1 W: Target Translations
(main/i18n/Translation-en_US) is configured multiple times in
/etc/apt/sources.list.d/yandex-browser-beta.list:3 and
/etc/apt/sources.list.d/yandex-browser.list:1 W: Target Translations
(main/i18n/Translation-en) is configured multiple times in
/etc/apt/sources.list.d/yandex-browser-beta.list:3 and
/etc/apt/sources.list.d/yandex-browser.list:1 W: Target DEP-11
(main/dep11/Components-amd64.yml) is configured multiple times in
/etc/apt/sources.list.d/yandex-browser-beta.list:3 and
/etc/apt/sources.list.d/yandex-browser.list:1 W: Target DEP-11-icons
(main/dep11/icons-64x64.tar) is configured multiple times in
/etc/apt/sources.list.d/yandex-browser-beta.list:3 and
/etc/apt/sources.list.d/yandex-browser.list:1 

vegan@vegan:~$ sudo apt-get upgrade tzdata tzdata-java 
Reading package lists... Done
Building dependency tree        
Reading state information... Done E:
Unable to locate package tzdata-java

也适用于

vegan@vegan:~$ sudo apt-get install tzdata-java
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package tzdata-java

还有我该如何制作 java?因为对于我的测试 Linux 机器,请参阅此

puapp@PU-APP-01:~$ java -jar tzupdater.jar -u -l https://www.iana.org/time-zones/repository/releases/tzdata2015g.tar.gz
The program 'java' can be found in the following packages:
 * default-jre
 * gcj-4.8-jre-headless
 * openjdk-7-jre-headless
 * gcj-4.6-jre-headless
 * openjdk-6-jre-headless
Try: sudo apt-get install <selected package>                       

因此 JRE 未安装,但应用程序现已启动。那么,我现在能做什么?如果我安装 JRE,会发生什么变化?当我运行时date,它已在控制台中显示正确的时间。我使用 Docker 生成了这个应用程序。

puapp@PU-APP-01:~$ java version
The program 'java' can be found in the following packages:
 * default-jre
 * gcj-4.8-jre-headless
 * openjdk-7-jre-headless
 * gcj-4.6-jre-headless
 * openjdk-6-jre-headless
Try: sudo apt-get install <selected package>


puapp@PU-APP-01:~$ whereis java
java: /usr/share/java

但在本地我有 java。

vegan@vegan:~$ java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

但本地并不重要。Linux 服务器很重要。

对于我们的主要机器,有 java

produp@Produp-app-01:~$ java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
produp@Produp-app-01:~$ 

现在时间是 00.44。当我跑步时

vegan@vegan:/usr/bin/tzdb$ date
Cum Kas  4 00:44:47 +03 2016

它返回正确的时间,但应用程序中的时间仍然晚了 1 小时。我不知道小时是否总是正确的。如果控制台显示真实小时,tzdata应用程序该怎么办?

答案1

嗯……通常所有关于时区和夏令时的政治决定都包含在时区数据tzdata-java包...因此,这些包的简单更新需要提供“当前”的政治时区......

这里是更改日志为了时区数据我明白了新的上游版本,包含土耳其夏令时变更 (LP: #1621373)添加于 2016-10-21。

sudo apt-get update
sudo apt-get upgrade tzdata

已编辑...

但是!!! 似乎不再有 tzdata-java - 请查看并按照以下答案中的链接进行操作Xenial 16.04 中的 tzdata-java 发生了什么?通过 PPA 寻找可能的解决方法。

相关内容