Date: Sat, 10 Feb 2024 22:53:52 +0100 From: <csab6597@gmail.com> To: <freebsd-java@FreeBSD.org> Subject: Issue: Java does not honor timezone setting Message-ID: <004901da5c6b$a36b1150$ea4133f0$@gmail.com>
index | next in thread | raw e-mail
[-- Attachment #1 --] 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=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!-- /* Font Definitions */ @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:Aptos;} @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; mso-ligatures:standardcontextual;} pre {mso-style-priority:99; mso-style-link:"HTML Vorformatiert Zchn"; margin:0cm; margin-bottom:.0001pt; font-size:10.0pt; font-family:"Courier New";} span.HTMLVorformatiertZchn {mso-style-name:"HTML Vorformatiert Zchn"; mso-style-priority:99; mso-style-link:"HTML Vorformatiert"; font-family:"Courier New"; mso-ligatures:none;} span.E-MailFormatvorlage20 {mso-style-type:personal-compose; font-family:"Aptos",sans-serif; color:windowtext;} .MsoChpDefault {mso-style-type:export-only; font-size:10.0pt; mso-ligatures:none;} @page WordSection1 {size:612.0pt 792.0pt; margin:70.85pt 70.85pt 2.0cm 70.85pt;} div.WordSection1 {page:WordSection1;} --></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="#467886" vlink="#96607D" style='word-wrap:break-word'><div class=WordSection1><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'>Hi there,<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'>I am using TrueNAS Core TrueNAS-13.0-U6.1 where in a jail I installed jdk 19. In the shell I get<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:#E8E8E8'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black;mso-ligatures:none'># java -version</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";mso-ligatures:none'><o:p></o:p></span></p><p class=MsoNormal style='background:#E8E8E8'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black;mso-ligatures:none'>openjdk version "19.0.2" 2023-01-17</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";mso-ligatures:none'><o:p></o:p></span></p><p class=MsoNormal style='background:#E8E8E8'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black;mso-ligatures:none'>OpenJDK Runtime Environment (build 19.0.2+7-1)</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";mso-ligatures:none'><o:p></o:p></span></p><p class=MsoNormal style='background:#E8E8E8'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black;mso-ligatures:none'>OpenJDK 64-Bit Server VM (build 19.0.2+7-1, mixed mode, sharing)</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";mso-ligatures:none'><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'>The issue I encountered is that java does not honor the timezone I have set in TrueNAS.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'>When using the builtin command in the TrueNAS shell I can see<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'><o:p> </o:p></span></p><pre style='background:#E8E8E8'><span lang=EN-US style='color:black'># date</span><span lang=EN-US><o:p></o:p></span></pre><pre style='background:#E8E8E8'><span lang=EN-US style='color:black'>Sat Feb 10 10:36:35 CET 2024</span><span lang=EN-US><o:p></o:p></span></pre><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'>So that command reports CET timezone which is in fact what it should be, what is set in TrueNAS system configuration<o:p></o:p></span></p><p class=MsoNormal><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<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'><o:p> </o:p></span></p><pre style='background:#E8E8E8'><span lang=EN-US style='color:black'># jshell</span><span lang=EN-US><o:p></o:p></span></pre><pre style='background:#E8E8E8'><span lang=EN-US style='color:black'>| Welcome to JShell -- Version 19.0.2</span><span lang=EN-US><o:p></o:p></span></pre><pre style='background:#E8E8E8'><span lang=EN-US style='color:black'>| For an introduction type: /help intro</span><span lang=EN-US><o:p></o:p></span></pre><pre style='background:#E8E8E8'><span lang=EN-US><o:p> </o:p></span></pre><pre style='background:#E8E8E8'><span lang=EN-US style='color:black'>jshell> java.time.ZonedDateTime.now()</span><span lang=EN-US><o:p></o:p></span></pre><pre style='background:#E8E8E8'><span lang=EN-US style='color:black'>$3 ==> 2024-02-10T09:38:12.192401862Z[GMT]</span><span lang=EN-US><o:p></o:p></span></pre><pre style='background:#E8E8E8'><span lang=EN-US><o:p> </o:p></span></pre><pre style='background:#E8E8E8'><span lang=EN-US style='color:black'>jshell> java.time.LocalDateTime.now()</span><span lang=EN-US><o:p></o:p></span></pre><pre style='background:#E8E8E8'><span lang=EN-US style='color:black'>$1 ==> 2024-02-10T09:38:12.192401862Z</span><span lang=EN-US><o:p></o:p></span></pre><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'>Also tested in Windows and Ubuntu where Java will indeed report the correct timezone<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'>Greets, Rainer <o:p></o:p></span></p></div></body></html>help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?004901da5c6b$a36b1150$ea4133f0$>
