Date: Wed, 14 Feb 2024 22:04:32 +0100 From: <csab6597@gmail.com> To: "'Michael Zhilin'" <mizhka@gmail.com> Cc: <freebsd-java@freebsd.org> Subject: AW: Issue: Java does not honor timezone setting Message-ID: <003a01da5f89$68dd1ad0$3a975070$@gmail.com> In-Reply-To: <CAF19XBKqgFnGVHUq%2BZBOBqXwwrb0TTDKq5R_h_ayGtsXU=_Cfw@mail.gmail.com> References: <004901da5c6b$a36b1150$ea4133f0$@gmail.com> <CAF19XBKqgFnGVHUq%2BZBOBqXwwrb0TTDKq5R_h_ayGtsXU=_Cfw@mail.gmail.com>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --] Hi Michael, I used tzsetup and selected Europe/Austria. After doing so I now get the correct time zone and therefore time value in java. # date Wed Feb 14 21:21:06 CET 2024 # jshell | Welcome to JShell – Version 19.0.2 | For an introduction type: /help intro jshell> java.time.ZonedDateTime.now() &1 ==> 2024-02-14T21_21_36.093531195+01:00[Europe/Vienna] Now the situation is like * When I change the TrueNAS systemwide timezone, which was always set to Europe/Vienna by the way, that is indeed reflected through the “date” command (but only after a system restart). But such a change is not adopted in Java. * Whereas the other way round, any change through tzsetup is indeed reflected in Java as well as in “date” At first I put up the following thread in the TrueNAS forum <https://www.truenas.com/community/threads/java-reporting-wrong-time-zone-in-jail.116366/> https://www.truenas.com/community/threads/java-reporting-wrong-time-zone-in-jail.116366/ from where I was pointed to you. Do you think I should now point back to some TrueNAS configuration issue? Greets, Rainer Von: Michael Zhilin <mizhka@gmail.com> Gesendet: Mittwoch, 14. Februar 2024 16:46 An: csab6597@gmail.com Cc: freebsd-java@freebsd.org Betreff: Re: Issue: Java does not honor timezone setting Hi, I've tried to use /usr/share/zoneinfo/CET as /etc/localtime and it seems java can't identify TZ correctly. But in case of particular country's TZ, it works fine: # tzsetup root@tamagawa /usr/share/zoneinfo # date Wed Feb 14 16:40:48 CET 2024 root@tamagawa /usr/share/zoneinfo # export JAVA_VERSION=17 root@tamagawa /usr/share/zoneinfo # jshell | Welcome to JShell -- Version 17.0.9 | For an introduction type: /help intro jshell> java.time.ZonedDateTime.now() $1 ==> 2024-02-14T16:41:13.106408203+01:00[Europe/Andorra] I have no access to TrueNAS & jdk19, could you please try to specify the country's TZ by tzsetup and check tz in java? Thanks! On Sun, Feb 11, 2024 at 12:53 AM <csab6597@gmail.com <mailto:csab6597@gmail.com> > wrote: 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 [-- Attachment #2 --] <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0;} @font-face {font-family:PMingLiU; panose-1:2 1 6 1 0 1 1 1 1 1;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} @font-face {font-family:Aptos;} @font-face {font-family:Consolas; panose-1:2 11 6 9 2 2 4 3 2 4;} @font-face {font-family:"\@PMingLiU"; panose-1:2 1 6 1 0 1 1 1 1 1;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0cm; font-size:12.0pt; font-family:"Aptos",sans-serif;} a:link, span.MsoHyperlink {mso-style-priority:99; color:blue; text-decoration:underline;} pre {mso-style-priority:99; mso-style-link:"HTML Vorformatiert Zchn"; margin:0cm; margin-bottom:.0001pt; font-size:10.0pt; font-family:"Courier New";} p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph {mso-style-priority:34; margin-top:0cm; margin-right:0cm; margin-bottom:0cm; margin-left:36.0pt; font-size:12.0pt; font-family:"Aptos",sans-serif;} span.HTMLVorformatiertZchn {mso-style-name:"HTML Vorformatiert Zchn"; mso-style-priority:99; mso-style-link:"HTML Vorformatiert"; font-family:Consolas; mso-ligatures:none;} span.E-MailFormatvorlage20 {mso-style-type:personal-reply; font-family:"Aptos",sans-serif; color:windowtext;} .MsoChpDefault {mso-style-type:export-only;} @page WordSection1 {size:612.0pt 792.0pt; margin:70.85pt 70.85pt 2.0cm 70.85pt;} div.WordSection1 {page:WordSection1;} /* List Definitions */ @list l0 {mso-list-id:737872014; mso-list-type:hybrid; mso-list-template-ids:1388315574 962094558 201785347 201785349 201785345 201785347 201785349 201785345 201785347 201785349;} @list l0:level1 {mso-level-start-at:0; mso-level-number-format:bullet; mso-level-text:-; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:20.25pt; text-indent:-18.0pt; font-family:"Aptos",sans-serif; mso-fareast-font-family:PMingLiU; mso-bidi-font-family:"Times New Roman";} @list l0:level2 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:56.25pt; text-indent:-18.0pt; font-family:"Courier New";} @list l0:level3 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:92.25pt; text-indent:-18.0pt; font-family:Wingdings;} @list l0:level4 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:128.25pt; text-indent:-18.0pt; font-family:Symbol;} @list l0:level5 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:164.25pt; text-indent:-18.0pt; font-family:"Courier New";} @list l0:level6 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:200.25pt; text-indent:-18.0pt; font-family:Wingdings;} @list l0:level7 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:236.25pt; text-indent:-18.0pt; font-family:Symbol;} @list l0:level8 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:272.25pt; text-indent:-18.0pt; font-family:"Courier New";} @list l0:level9 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:308.25pt; text-indent:-18.0pt; font-family:Wingdings;} ol {margin-bottom:0cm;} ul {margin-bottom:0cm;} --></style><!--[if gte mso 9]><xml> <o:shapedefaults v:ext="edit" spidmax="1026" /> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout v:ext="edit"> <o:idmap v:ext="edit" data="1" /> </o:shapelayout></xml><![endif]--></head><body lang=DE-AT link=blue vlink=purple style='word-wrap:break-word'><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt'>Hi Michael,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'>I used tzsetup and selected Europe/Austria. After doing so I now get the correct time zone and therefore time value in java.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'><o:p> </o:p></span></p><p class=MsoNormal style='background:#F2F2F2'><span lang=EN-US style='font-size:11.0pt;color:black'># date</span><span lang=EN-US style='font-size:11.0pt'><o:p></o:p></span></p><p class=MsoNormal style='background:#F2F2F2'><span lang=EN-US style='font-size:11.0pt;color:black'>Wed Feb 14 21:21:06 CET 2024</span><span lang=EN-US style='font-size:11.0pt'><o:p></o:p></span></p><p class=MsoNormal style='background:#F2F2F2'><span lang=EN-US style='font-size:11.0pt'><o:p> </o:p></span></p><p class=MsoNormal style='background:#F2F2F2'><span lang=EN-US style='font-size:11.0pt;color:black'># jshell</span><span lang=EN-US style='font-size:11.0pt'><o:p></o:p></span></p><p class=MsoNormal style='background:#F2F2F2'><span lang=EN-US style='font-size:11.0pt;color:black'>| Welcome to JShell – Version 19.0.2</span><span lang=EN-US style='font-size:11.0pt'><o:p></o:p></span></p><p class=MsoNormal style='background:#F2F2F2'><span lang=EN-US style='font-size:11.0pt;color:black'>| For an introduction type: /help intro</span><span lang=EN-US style='font-size:11.0pt'><o:p></o:p></span></p><p class=MsoNormal style='background:#F2F2F2'><span lang=EN-US style='font-size:11.0pt'><o:p> </o:p></span></p><p class=MsoNormal style='background:#F2F2F2'><span lang=EN-US style='font-size:11.0pt;color:black'>jshell> java.time.ZonedDateTime.now()</span><span lang=EN-US style='font-size:11.0pt'><o:p></o:p></span></p><p class=MsoNormal style='background:#F2F2F2'><span lang=EN-US style='font-size:11.0pt;color:black'>&1 ==> 2024-02-14T21_21_36.093531195+01:00[Europe/Vienna]</span><span lang=EN-US style='font-size:11.0pt'><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'>Now the situation is like<o:p></o:p></span></p><ul style='margin-top:0cm' type=disc><li class=MsoListParagraph style='margin-left:-15.75pt;mso-list:l0 level1 lfo1'><span lang=EN-US style='font-size:11.0pt'>When I change the TrueNAS systemwide timezone, which was always set to Europe/Vienna by the way, that is indeed reflected through the “date” command (but only after a system restart). But such a change is not adopted in Java.<o:p></o:p></span></li><li class=MsoListParagraph style='margin-left:-15.75pt;mso-list:l0 level1 lfo1'><span lang=EN-US style='font-size:11.0pt'>Whereas the other way round, any change through tzsetup is indeed reflected in Java as well as in “date”<o:p></o:p></span></li></ul><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'>At first I put up the following thread in the TrueNAS forum </span><span style='font-size:11.0pt'><a href="https://www.truenas.com/community/threads/java-reporting-wrong-time-zone-in-jail.116366/"><span lang=EN-US>https://www.truenas.com/community/threads/java-reporting-wrong-time-zone-in-jail.116366/</span></a></span><span style='font-size:11.0pt'> <span lang=EN-US>from where I was pointed to you. Do you think I should now point back to some TrueNAS configuration issue?<o:p></o:p></span></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'>Greets, Rainer<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'><o:p> </o:p></span></p><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=DE style='font-size:11.0pt;font-family:"Calibri",sans-serif'>Von:</span></b><span lang=DE style='font-size:11.0pt;font-family:"Calibri",sans-serif'> Michael Zhilin <mizhka@gmail.com> <br><b>Gesendet:</b> Mittwoch, 14. Februar 2024 16:46<br><b>An:</b> csab6597@gmail.com<br><b>Cc:</b> freebsd-java@freebsd.org<br><b>Betreff:</b> Re: Issue: Java does not honor timezone setting<o:p></o:p></span></p></div><p class=MsoNormal><o:p> </o:p></p><div><div><p class=MsoNormal>Hi,<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>I've tried to use /usr/share/zoneinfo/CET as /etc/localtime and it seems java can't identify TZ correctly.<o:p></o:p></p></div><div><p class=MsoNormal>But in case of particular country's TZ, it works fine:<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal> # tzsetup<br>root@tamagawa /usr/share/zoneinfo<br> # date<br>Wed Feb 14 16:40:48 CET 2024<br>root@tamagawa /usr/share/zoneinfo<br> # export JAVA_VERSION=17<br>root@tamagawa /usr/share/zoneinfo<br> # jshell<br>| Welcome to JShell -- Version 17.0.9<br>| For an introduction type: /help intro<br><br>jshell> java.time.ZonedDateTime.now()<br>$1 ==> 2024-02-14T16:41:13.106408203+01:00[Europe/Andorra]<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>I have no access to TrueNAS & jdk19, could you please try to specify the country's TZ by tzsetup and check tz in java?<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Thanks!<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div></div><p class=MsoNormal><o:p> </o:p></p><div><div><p class=MsoNormal>On Sun, Feb 11, 2024 at 12:53<span style='font-family:"Arial",sans-serif'> </span>AM <<a href="mailto:csab6597@gmail.com">csab6597@gmail.com</a>> wrote:<o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm'><div><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt'>Hi there,</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt'>I am using TrueNAS Core TrueNAS-13.0-U6.1 where in a jail I installed jdk 19. In the shell I get</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;background:#E8E8E8'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'># java -version</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;background:#E8E8E8'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>openjdk version "19.0.2" 2023-01-17</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;background:#E8E8E8'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>OpenJDK Runtime Environment (build 19.0.2+7-1)</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;background:#E8E8E8'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>OpenJDK 64-Bit Server VM (build 19.0.2+7-1, mixed mode, sharing)</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt'>The issue I encountered is that java does not honor the timezone I have set in TrueNAS.</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt'>When using the builtin command in the TrueNAS shell I can see</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt'> </span><o:p></o:p></p><pre style='background:#E8E8E8'><span lang=EN-US style='color:black'># date</span><o:p></o:p></pre><pre style='background:#E8E8E8'><span lang=EN-US style='color:black'>Sat Feb 10 10:36:35 CET 2024</span><o:p></o:p></pre><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt'>So that command reports CET timezone which is in fact what it should be, what is set in TrueNAS system configuration</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt'>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</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt'> </span><o:p></o:p></p><pre style='background:#E8E8E8'><span lang=EN-US style='color:black'># jshell</span><o:p></o:p></pre><pre style='background:#E8E8E8'><span lang=EN-US style='color:black'>| Welcome to JShell -- Version 19.0.2</span><o:p></o:p></pre><pre style='background:#E8E8E8'><span lang=EN-US style='color:black'>| For an introduction type: /help intro</span><o:p></o:p></pre><pre style='background:#E8E8E8'><span lang=EN-US style='color:black'> </span><o:p></o:p></pre><pre style='background:#E8E8E8'><span lang=EN-US style='color:black'>jshell> java.time.ZonedDateTime.now()</span><o:p></o:p></pre><pre style='background:#E8E8E8'><span lang=EN-US style='color:black'>$3 ==> 2024-02-10T09:38:12.192401862Z[GMT]</span><o:p></o:p></pre><pre style='background:#E8E8E8'><span lang=EN-US style='color:black'> </span><o:p></o:p></pre><pre style='background:#E8E8E8'><span lang=EN-US style='color:black'>jshell> java.time.LocalDateTime.now()</span><o:p></o:p></pre><pre style='background:#E8E8E8'><span lang=EN-US style='color:black'>$1 ==> 2024-02-10T09:38:12.192401862Z</span><o:p></o:p></pre><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt'>Also tested in Windows and Ubuntu where Java will indeed report the correct timezone</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt'>Greets, Rainer </span><o:p></o:p></p></div></div></div></blockquote></div></div></body></html>help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?003a01da5f89$68dd1ad0$3a975070$>
