Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Feb 2024 18:46:05 +0300
From:      Michael Zhilin <mizhka@gmail.com>
To:        csab6597@gmail.com
Cc:        freebsd-java@freebsd.org
Subject:   Re: Issue: Java does not honor timezone setting
Message-ID:  <CAF19XBKqgFnGVHUq%2BZBOBqXwwrb0TTDKq5R_h_ayGtsXU=_Cfw@mail.gmail.com>
In-Reply-To: <004901da5c6b$a36b1150$ea4133f0$@gmail.com>
References:  <004901da5c6b$a36b1150$ea4133f0$@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--00000000000056fc140611596948
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

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=3D17
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 =3D=3D> 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=E2=80=AFAM <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 offs=
et
> to the actual time
>
>
>
> # jshell
>
> |  Welcome to JShell -- Version 19.0.2
>
> |  For an introduction type: /help intro
>
>
>
> jshell> java.time.ZonedDateTime.now()
>
> $3 =3D=3D> 2024-02-10T09:38:12.192401862Z[GMT]
>
>
>
> jshell> java.time.LocalDateTime.now()
>
> $1 =3D=3D> 2024-02-10T09:38:12.192401862Z
>
>
>
>
>
> Also tested in Windows and Ubuntu where Java will indeed report the
> correct timezone
>
>
>
> Greets, Rainer
>

--00000000000056fc140611596948
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hi,</div><div><br></div><div>I&#39;ve tried to use /u=
sr/share/zoneinfo/CET as /etc/localtime and it seems java can&#39;t identif=
y TZ correctly.</div><div>But in case of particular country&#39;s TZ, it wo=
rks fine:</div><div><br></div><div>=C2=A0# tzsetup<br>root@tamagawa /usr/sh=
are/zoneinfo<br>=C2=A0# date<br>Wed Feb 14 16:40:48 CET 2024<br>root@tamaga=
wa /usr/share/zoneinfo<br>=C2=A0# export JAVA_VERSION=3D17<br>root@tamagawa=
 /usr/share/zoneinfo<br>=C2=A0# jshell<br>| =C2=A0Welcome to JShell -- Vers=
ion 17.0.9<br>| =C2=A0For an introduction type: /help intro<br><br>jshell&g=
t; java.time.ZonedDateTime.now()<br>$1 =3D=3D&gt; 2024-02-14T16:41:13.10640=
8203+01:00[Europe/Andorra]</div><div><br></div><div>I have no access to Tru=
eNAS &amp; jdk19, could you please try to specify the country&#39;s TZ by t=
zsetup and check tz in java?</div><div><br></div><div>Thanks!<br></div><div=
><br></div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"g=
mail_attr">On Sun, Feb 11, 2024 at 12:53=E2=80=AFAM &lt;<a href=3D"mailto:c=
sab6597@gmail.com">csab6597@gmail.com</a>&gt; wrote:<br></div><blockquote c=
lass=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px soli=
d rgb(204,204,204);padding-left:1ex"><div class=3D"msg-2397408257342209182"=
><div lang=3D"DE-AT" style=3D"overflow-wrap: break-word;"><div class=3D"m_-=
2397408257342209182WordSection1"><p class=3D"MsoNormal"><span lang=3D"EN-US=
" style=3D"font-size:11pt">Hi there,<u></u><u></u></span></p><p class=3D"Ms=
oNormal"><span lang=3D"EN-US" style=3D"font-size:11pt"><u></u>=C2=A0<u></u>=
</span></p><p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:1=
1pt">I am using TrueNAS Core TrueNAS-13.0-U6.1 where in a jail I installed =
jdk 19. In the shell I get<u></u><u></u></span></p><p class=3D"MsoNormal"><=
span lang=3D"EN-US" style=3D"font-size:11pt"><u></u>=C2=A0<u></u></span></p=
><p class=3D"MsoNormal" style=3D"background:rgb(232,232,232)"><span lang=3D=
"EN-US" style=3D"font-size:10pt;font-family:&quot;Courier New&quot;;color:b=
lack"># java -version</span><span lang=3D"EN-US" style=3D"font-size:10pt;fo=
nt-family:&quot;Courier New&quot;"><u></u><u></u></span></p><p class=3D"Mso=
Normal" style=3D"background:rgb(232,232,232)"><span lang=3D"EN-US" style=3D=
"font-size:10pt;font-family:&quot;Courier New&quot;;color:black">openjdk ve=
rsion &quot;19.0.2&quot; 2023-01-17</span><span lang=3D"EN-US" style=3D"fon=
t-size:10pt;font-family:&quot;Courier New&quot;"><u></u><u></u></span></p><=
p class=3D"MsoNormal" style=3D"background:rgb(232,232,232)"><span lang=3D"E=
N-US" style=3D"font-size:10pt;font-family:&quot;Courier New&quot;;color:bla=
ck">OpenJDK Runtime Environment (build 19.0.2+7-1)</span><span lang=3D"EN-U=
S" style=3D"font-size:10pt;font-family:&quot;Courier New&quot;"><u></u><u><=
/u></span></p><p class=3D"MsoNormal" style=3D"background:rgb(232,232,232)">=
<span lang=3D"EN-US" style=3D"font-size:10pt;font-family:&quot;Courier New&=
quot;;color:black">OpenJDK 64-Bit Server VM (build 19.0.2+7-1, mixed mode, =
sharing)</span><span lang=3D"EN-US" style=3D"font-size:10pt;font-family:&qu=
ot;Courier New&quot;"><u></u><u></u></span></p><p class=3D"MsoNormal"><span=
 lang=3D"EN-US" style=3D"font-size:11pt"><u></u>=C2=A0<u></u></span></p><p =
class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:11pt">The issue=
 I encountered is that java does not honor the timezone I have set in TrueN=
AS.<u></u><u></u></span></p><p class=3D"MsoNormal"><span lang=3D"EN-US" sty=
le=3D"font-size:11pt">When using the builtin command =C2=A0in the TrueNAS s=
hell I can see<u></u><u></u></span></p><p class=3D"MsoNormal"><span lang=3D=
"EN-US" style=3D"font-size:11pt"><u></u>=C2=A0<u></u></span></p><pre style=
=3D"background:rgb(232,232,232)"><span lang=3D"EN-US" style=3D"color:black"=
># date</span><span lang=3D"EN-US"><u></u><u></u></span></pre><pre style=3D=
"background:rgb(232,232,232)"><span lang=3D"EN-US" style=3D"color:black">Sa=
t Feb 10 10:36:35 CET 2024</span><span lang=3D"EN-US"><u></u><u></u></span>=
</pre><p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:11pt">=
<u></u>=C2=A0<u></u></span></p><p class=3D"MsoNormal"><span lang=3D"EN-US" =
style=3D"font-size:11pt">So that command reports CET timezone which is in f=
act what it should be, what is set in TrueNAS system configuration<u></u><u=
></u></span></p><p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-s=
ize:11pt">But inside java, for a test just using jshell, then java will rep=
ort GMT which means java is ignoring the timezone setting and thus giving a=
n offset to the actual time<u></u><u></u></span></p><p class=3D"MsoNormal">=
<span lang=3D"EN-US" style=3D"font-size:11pt"><u></u>=C2=A0<u></u></span></=
p><pre style=3D"background:rgb(232,232,232)"><span lang=3D"EN-US" style=3D"=
color:black"># jshell</span><span lang=3D"EN-US"><u></u><u></u></span></pre=
><pre style=3D"background:rgb(232,232,232)"><span lang=3D"EN-US" style=3D"c=
olor:black">|=C2=A0 Welcome to JShell -- Version 19.0.2</span><span lang=3D=
"EN-US"><u></u><u></u></span></pre><pre style=3D"background:rgb(232,232,232=
)"><span lang=3D"EN-US" style=3D"color:black">|=C2=A0 For an introduction t=
ype: /help intro</span><span lang=3D"EN-US"><u></u><u></u></span></pre><pre=
 style=3D"background:rgb(232,232,232)"><span lang=3D"EN-US"><u></u>=C2=A0<u=
></u></span></pre><pre style=3D"background:rgb(232,232,232)"><span lang=3D"=
EN-US" style=3D"color:black">jshell&gt; java.time.ZonedDateTime.now()</span=
><span lang=3D"EN-US"><u></u><u></u></span></pre><pre style=3D"background:r=
gb(232,232,232)"><span lang=3D"EN-US" style=3D"color:black">$3 =3D=3D&gt; 2=
024-02-10T09:38:12.192401862Z[GMT]</span><span lang=3D"EN-US"><u></u><u></u=
></span></pre><pre style=3D"background:rgb(232,232,232)"><span lang=3D"EN-U=
S"><u></u>=C2=A0<u></u></span></pre><pre style=3D"background:rgb(232,232,23=
2)"><span lang=3D"EN-US" style=3D"color:black">jshell&gt; java.time.LocalDa=
teTime.now()</span><span lang=3D"EN-US"><u></u><u></u></span></pre><pre sty=
le=3D"background:rgb(232,232,232)"><span lang=3D"EN-US" style=3D"color:blac=
k">$1 =3D=3D&gt; 2024-02-10T09:38:12.192401862Z</span><span lang=3D"EN-US">=
<u></u><u></u></span></pre><p class=3D"MsoNormal"><span lang=3D"EN-US" styl=
e=3D"font-size:11pt"><u></u>=C2=A0<u></u></span></p><p class=3D"MsoNormal">=
<span lang=3D"EN-US" style=3D"font-size:11pt"><u></u>=C2=A0<u></u></span></=
p><p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:11pt">Also=
 tested in Windows and Ubuntu where Java will indeed report the correct tim=
ezone<u></u><u></u></span></p><p class=3D"MsoNormal"><span lang=3D"EN-US" s=
tyle=3D"font-size:11pt"><u></u>=C2=A0<u></u></span></p><p class=3D"MsoNorma=
l"><span lang=3D"EN-US" style=3D"font-size:11pt">Greets, Rainer <u></u><u><=
/u></span></p></div></div></div></blockquote></div>

--00000000000056fc140611596948--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAF19XBKqgFnGVHUq%2BZBOBqXwwrb0TTDKq5R_h_ayGtsXU=_Cfw>