4

I have a microservice written in Java + using Spring Boot. I developed it on Windows 10 using Java version 1.8.0_221. Now I want to run this on Ubuntu 18.04. On Ubuntu machine I have OpenJDK 1.8.0_40-b25.

When I run this on Windows machine the time displayed on console messages(I print them using log4j2) and time of stuff I save on database(using @CreatedDate and @Temopral(TemporalType.TIMESTAMP) annotation on a Date field) is correct and my ZoneId.systemDefault is Europe/Istanbul.

It is also Europe/Istanbul on my Ubuntu machine.

However when I run this on Ubuntu machine the time is 1 hour behind the system time I get by typing "date" on terminal. All the times on logs I print to console and my database insertions are off by one hour.

I have searched other similar questions but they all focused on timezones, I don't think in any part of the program I am modifying the timezone. Also my Ubuntu time being correct makes me thing I need to change something with JVM maybe?

bobku123
  • 81
  • 9
  • 2
    are the shown system times of windows and ubuntu equal? – Jakob F Feb 10 '20 at 13:30
  • Yes, didn't check second-by-second but they are equal to the minutes. – bobku123 Feb 10 '20 at 13:34
  • 3
    Unsure: Turkey had changed its DST settings in 2019, of which your Ubuntu 18.04 might not be aware of. I have no experience with Turkish time or java updates of locale specific data, but that would be one very prosaic explanation. Check the UTC times. – Joop Eggen Feb 10 '20 at 13:39
  • 1
    Yes Turkey did stop doing daylight savings but my ubuntu time is correct. I tought java would simply pull operating system's time. – bobku123 Feb 10 '20 at 13:41
  • Looks like DST issue, check this : https://docs.oracle.com/javase/9/troubleshoot/time-zone-settings-jre.htm#JSTGD366 – brijesh Feb 10 '20 at 13:41
  • 3
    Java has its own timezone database. – Thilo Feb 10 '20 at 13:53
  • @Thilo True. Does that fact explain anything here? – Ole V.V. Feb 10 '20 at 14:42
  • 1
    Are those annotations coming from Spring Data rather than Spring Boot? If so, you should edit your tags and text to tell the whole story. – Basil Bourque Feb 10 '20 at 23:56

1 Answers1

0

I have tried to update the timezone database following the answer to this question this but could not get it to work. So I decided to remove OpenJDK and install Oracle JDK 8 instead and it works fine now.

bobku123
  • 81
  • 9