Issue: Java does not honor timezone setting
- Reply: Michael Zhilin : "Re: Issue: Java does not honor timezone setting"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 10 Feb 2024 21:53:52 UTC
Hi there, I am using TrueNAS Core TrueNAS-13.0-U6.1 where in a jail I installed jdk 19. In the shell I get # java -version openjdk version "19.0.2" 2023-01-17 OpenJDK Runtime Environment (build 19.0.2+7-1) OpenJDK 64-Bit Server VM (build 19.0.2+7-1, mixed mode, sharing) The issue I encountered is that java does not honor the timezone I have set in TrueNAS. When using the builtin command in the TrueNAS shell I can see # date Sat Feb 10 10:36:35 CET 2024 So that command reports CET timezone which is in fact what it should be, what is set in TrueNAS system configuration But inside java, for a test just using jshell, then java will report GMT which means java is ignoring the timezone setting and thus giving an offset to the actual time # jshell | Welcome to JShell -- Version 19.0.2 | For an introduction type: /help intro jshell> java.time.ZonedDateTime.now() $3 ==> 2024-02-10T09:38:12.192401862Z[GMT] jshell> java.time.LocalDateTime.now() $1 ==> 2024-02-10T09:38:12.192401862Z Also tested in Windows and Ubuntu where Java will indeed report the correct timezone Greets, Rainer