Skip site navigation (1)Skip section navigation (2)
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>

next in thread | raw e-mail | index | archive | help
This is a multipart message in MIME format.

------=_NextPart_000_004A_01DA5C74.0530B1D0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

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 


------=_NextPart_000_004A_01DA5C74.0530B1D0
Content-Type: text/html;
	boundary="----=_NextPart_000_002C_01DA5C72.F2D34490";
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" =
xmlns=3D"http://www.w3.org/TR/REC-html40"><head><meta =
http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii"><meta name=3DGenerator content=3D"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=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]--></head><body lang=3DDE-AT =
link=3D"#467886" vlink=3D"#96607D" style=3D'word-wrap:break-word'><div =
class=3DWordSection1><p class=3DMsoNormal><span lang=3DEN-US =
style=3D'font-size:11.0pt'>Hi there,<o:p></o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US =
style=3D'font-size:11.0pt'><o:p>&nbsp;</o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US style=3D'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=3DMsoNormal><span =
lang=3DEN-US style=3D'font-size:11.0pt'><o:p>&nbsp;</o:p></span></p><p =
class=3DMsoNormal style=3D'background:#E8E8E8'><span lang=3DEN-US =
style=3D'font-size:10.0pt;font-family:"Courier =
New";color:black;mso-ligatures:none'># java -version</span><span =
lang=3DEN-US style=3D'font-size:10.0pt;font-family:"Courier =
New";mso-ligatures:none'><o:p></o:p></span></p><p class=3DMsoNormal =
style=3D'background:#E8E8E8'><span lang=3DEN-US =
style=3D'font-size:10.0pt;font-family:"Courier =
New";color:black;mso-ligatures:none'>openjdk version &quot;19.0.2&quot; =
2023-01-17</span><span lang=3DEN-US =
style=3D'font-size:10.0pt;font-family:"Courier =
New";mso-ligatures:none'><o:p></o:p></span></p><p class=3DMsoNormal =
style=3D'background:#E8E8E8'><span lang=3DEN-US =
style=3D'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=3DEN-US =
style=3D'font-size:10.0pt;font-family:"Courier =
New";mso-ligatures:none'><o:p></o:p></span></p><p class=3DMsoNormal =
style=3D'background:#E8E8E8'><span lang=3DEN-US =
style=3D'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=3DEN-US =
style=3D'font-size:10.0pt;font-family:"Courier =
New";mso-ligatures:none'><o:p></o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US =
style=3D'font-size:11.0pt'><o:p>&nbsp;</o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US style=3D'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=3DMsoNormal><span lang=3DEN-US =
style=3D'font-size:11.0pt'>When using the builtin command &nbsp;in the =
TrueNAS shell I can see<o:p></o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-US style=3D'font-size:11.0pt'><o:p>&nbsp;</o:p></span></p><pre =
style=3D'background:#E8E8E8'><span lang=3DEN-US style=3D'color:black'># =
date</span><span lang=3DEN-US><o:p></o:p></span></pre><pre =
style=3D'background:#E8E8E8'><span lang=3DEN-US =
style=3D'color:black'>Sat Feb 10 10:36:35 CET 2024</span><span =
lang=3DEN-US><o:p></o:p></span></pre><p class=3DMsoNormal><span =
lang=3DEN-US style=3D'font-size:11.0pt'><o:p>&nbsp;</o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US style=3D'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=3DMsoNormal><span lang=3DEN-US style=3D'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=3DMsoNormal><span lang=3DEN-US =
style=3D'font-size:11.0pt'><o:p>&nbsp;</o:p></span></p><pre =
style=3D'background:#E8E8E8'><span lang=3DEN-US style=3D'color:black'># =
jshell</span><span lang=3DEN-US><o:p></o:p></span></pre><pre =
style=3D'background:#E8E8E8'><span lang=3DEN-US =
style=3D'color:black'>|&nbsp; Welcome to JShell -- Version =
19.0.2</span><span lang=3DEN-US><o:p></o:p></span></pre><pre =
style=3D'background:#E8E8E8'><span lang=3DEN-US =
style=3D'color:black'>|&nbsp; For an introduction type: /help =
intro</span><span lang=3DEN-US><o:p></o:p></span></pre><pre =
style=3D'background:#E8E8E8'><span =
lang=3DEN-US><o:p>&nbsp;</o:p></span></pre><pre =
style=3D'background:#E8E8E8'><span lang=3DEN-US =
style=3D'color:black'>jshell&gt; =
java.time.ZonedDateTime.now()</span><span =
lang=3DEN-US><o:p></o:p></span></pre><pre =
style=3D'background:#E8E8E8'><span lang=3DEN-US style=3D'color:black'>$3 =
=3D=3D&gt; 2024-02-10T09:38:12.192401862Z[GMT]</span><span =
lang=3DEN-US><o:p></o:p></span></pre><pre =
style=3D'background:#E8E8E8'><span =
lang=3DEN-US><o:p>&nbsp;</o:p></span></pre><pre =
style=3D'background:#E8E8E8'><span lang=3DEN-US =
style=3D'color:black'>jshell&gt; =
java.time.LocalDateTime.now()</span><span =
lang=3DEN-US><o:p></o:p></span></pre><pre =
style=3D'background:#E8E8E8'><span lang=3DEN-US style=3D'color:black'>$1 =
=3D=3D&gt; 2024-02-10T09:38:12.192401862Z</span><span =
lang=3DEN-US><o:p></o:p></span></pre><p class=3DMsoNormal><span =
lang=3DEN-US style=3D'font-size:11.0pt'><o:p>&nbsp;</o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US =
style=3D'font-size:11.0pt'><o:p>&nbsp;</o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US style=3D'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=3DMsoNormal><span lang=3DEN-US =
style=3D'font-size:11.0pt'><o:p>&nbsp;</o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US style=3D'font-size:11.0pt'>Greets, =
Rainer <o:p></o:p></span></p></div></body></html>
------=_NextPart_000_004A_01DA5C74.0530B1D0--




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?004901da5c6b$a36b1150$ea4133f0$>