One houre difference in data reading via rule

I have a rule for data reading, but to read a correct data from midnight, I must read one hour before :

val ZonedDateTime zdt =
val actual_day = zdt.minusDays(1).withHour(23).withMinute(0).withSecond(0)
val number = Modbus_Data_Grid_sum_2634_Value_as_Number.historicState(actual_day).state as Number
postUpdate(number_item, number)  

this value is

but if I will check in the graph, readed value is exactly in midnight

So question is, why there is one our difference and how to modify to read in the rule exactly in midnight and not one houre before midnight.

That line is flat. How do you know it’s one hour before midnight and not 6 hours before midnight or five hours later?

You are asking for the value at zdt.minusDays(1).withHour(23).withMinute(0).withSecond(0) which is exactly one hour before midnight on the previous day. So change the withHour to 0.

If I will change to withHour(0) then readed value is wrong - not from the midnight but from

Then that means you have the tiemzone set wrong somewhere. Either OH’s location settings, the timezone setting on the Java that is running OH, the operating system timezone, or the timezone setting of your database is wrong.

Also be aware in Grafana the charts will always only use GMT for the time scale. That is a deliberate choice made by the developers of Grafana and they are not going to change it.

ok, what where I can check to repair it ? I checked OS config and there is time ok.

For Java you can set the timezone in the JAVA_EXTRAOPTs OH3 does not respect the local timezone - #7 by Rob_Clark

For OH itself see Settings->Regional Settings.

For the database…:person_shrugging: You don’t say what database you are using.

Database I am using default
Regional settings in OH I already checked. They are ok.

rrd4j will get the timezone from Java.

Ok, Java settings I can check via any command via putty?

If you search for “-Duser” you will find one of the dozens of threads related to the topic of setting the Java timezone.

Log in to the karaf console and run:

 env |grep timezone

Result will show something like:

String          user.timezone   Europe/Berlin

ok, there is a error :

I’m not a London timezone

How to change ?
It’s very strange, because in OH timezone is ok, also in main OS is ok

This is a linux / openhabian installation ?
Check the content of /etc/default/openhab for variable EXTRA_JAVA_OPTS
Does it contain a setting for -Duser.timezone ?

it’s dietpi and then java 11 installation and openhab installation


As long as there is no other EXTRA_JAVA_OPTS in that file then


means that no additional options are set.
The lines that start with # are comments.

Sure that your system timezone is not set to Europe/London ?

cat /etc/timezone

yes, OS timezone is ok:

same timezone I have also in OH3 regional settings:


Please check if editing /etc/default/openhab already helps:


Restart openhab service afterwards.

really don’t know whats happened, but aftere restart looks like a timezone is now ok:
really strange