OH3 does not respect the local timezone

Seems OH3 does not respect the local timezone.

  • I have set my timezone
  • I have restarted OH3
  • But OH3 logs are still showing wrong times (USA/LA)
root@openHAB:~# ls -l /etc/localtime
lrwxrwxrwx 1 root root 35 May  4 12:36 /etc/localtime -> /usr/share/zoneinfo/Australia/Perth
root@openHAB:~# date
Tue May  4 14:00:19 AWST 2021
root@openHAB:~# service openhab restart
tail $OPENHAB_LOGDIR/openhab.log
2021-05-03 23:02:47.448 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Time zone set to 'Australia/Perth'.
2021-05-03 23:02:47.486 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Location set to '-32.02732708763323,115.77975690364839'.
2021-05-03 23:02:47.497 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Locale set to 'en_AU'.

As you can see OH3 is seeing the local TZ:
Time zone set to 'Australia/Perth'

But the timestamps are not correct in the log file.
Instead … they represent USA/Los Angeles time.

How do I get the correct timestamps in the log file?

BTW … this investigation started when my Rules were firing at the wrong times.

See Wrong timezone only for rules?

Try sudo dpkg-reconfigure tzdata
that might reset it?

@Wolfgang_S
Thanks - that confirms my LA theory

root@openHAB:~# reboot
[...]
root@openHAB:~# date
Tue May  4 14:42:48 AWST 2021
root@openHAB:~# openhab-cli console -p habopen env | grep timezone
String          user.timezone   America/Los_Angeles

root@openHAB:~# ls -l /etc/localtime
lrwxrwxrwx 1 root root 35 May  4 14:45 /etc/localtime -> /usr/share/zoneinfo/Australia/Perth
root@openHAB:~# cat /etc/timezone
Australia/Perth

So my system TZ = Australia/Perth, but Java TZ is America/Los_Angeles

I have read the link you pointed me to … but it does not mention a fix.

How do I get the Java TZ correct?

In the webuid you have the possibility to set a timezone ( Settings => Regional Settings ).
If that does not help you also can set a timezone in /etc/default/openhab.
There are examples for the variable to be ( EXTRA_JAVA_OPTS ) in the /etc/default/openhab file.

But the logger uses the Java locale,not openHABs.

Bingo!

  • WEBUI => Settings => Regional Settings. These were already set to Australia/Perth but that did not affect the log file timestamps.
  • But !!! adding the following to /etc/default/openhab (and restarting openhab) DID fix the timestamps.

EXTRA_JAVA_OPTS="-Duser.timezone=Australia/Perth"

Thank you.

Bit of a pity that with the TZ correctly set in the linux system, and OH3 Admin Settings … it is still is not respected in the logs.

I will see tomorrow if setting EXTRA_JAVA_OPTS="-Duser.timezone=Australia/Perth" fixes my Rules cron triggers.

What did you do when you installed Java? It usually tries to inherit from host OS.

Can’t remember if I installed Java before or after I set the TZ???

But … again … bit of a pity that on a reboot, (Zulu) JAVA does not take any notice of the system TZ. Seems a JAVA bug to me??? The ‘default’ JAVA TZ should not be USA/LA … but the System TZ.

Thanks for all the help. I would never have got this resolved by myself.

:slight_smile:

Happy to report that my rules ‘cron’ triggers now occur in my local TZ after making the change above.

Just came here to say thank you for documenting this. Your solution worked perfectly for me!