1

Turkey decided recently (September 6, 2016 ) to permanently stay in Daylight Saving Time (DST). This act canceled the ending of DST previously scheduled for October 30, 2016, 04:00:00. Clocks were not changed.

Turkey is between +2 and +3 utc, so now it will stay in +3. Here you can see

https://www.timeanddate.com/time/change/turkey/ankara?year=2016

*Information above is taken from this link of which problem is similar with mine. (Java timezone in turkey (rejected daylight saving))

Until today, manufacturers have provided some solutions about it. For example, Windows configured a timezone - (UTC+03:00) Istanbul - for Turkey. However, some problems about the same topic still continues like mine.

I develop Java web application that uses jdk1.8.0_101. I make it run over Apache Tomcat 7.0. In this application sometimes I use date objects. But, when I get date object (new Date()), I see that default timezone of JVM is different from the timezone of OS(Windows but different versions) that the application runs over.

I test it on three different environment. I use same java code and same jdk version in each environment. Java code is;

TimeZone zone = TimeZone.getDefault();
System.out.println(zone.getDisplayName());
System.out.println(zone.getID());

TEST CASE-1) My laptop - Windows 10 Pro (Administrator user) - new Date() object returns Wed Dec 21 10:00:38 EET 2016 Test Code Result:

Eastern European Time
Asia/Istanbul

enter image description here

==================================

TEST CASE-2) My Dektop PC - Windows 7 Service Pack 1 (Restricted user on the company network) - new Date object returns Wed Dec 21 10:00:38 EET 2016 Test Code Result:

Eastern European Time
Asia/Istanbul

enter image description here

==================================

TEST CASE-3) Virtual Server - Windows Server 2008 R2 Enterprise (Administrator user) - new Date object returns Wed Dec 21 11:03:11 GMT+03:00 2016 Test Code Result:

GMT+03:00
GMT+03:00

enter image description here

==================================

**** In 3rd test case, virtual server returns right date information, but in others, they return wrong date. I know that I can set timezone while getting date object. However, the project is big and it means a lot of date object that I have to correct it. Also, 3rd test case shows us that the problem can be solved by configuring the system date/time. What can I do about it? I wait for your recommendations.

Community
  • 1
  • 1
séan35
  • 966
  • 2
  • 13
  • 37
  • 2
    "But, when I get date object (new Date()), timezone of the object is different from timezone of operating system(Windows)" `Date` doesn't actually have a time zone. The only sense in which it uses a timezone is that `Date.toString()` uses the JVM's default timezone; so your question might be simplified to "why is the JVM's default timezone different in these cases". – Andy Turner Dec 21 '16 at 08:46
  • @AndyTurner I am editing the question based on your recommendation! – séan35 Dec 21 '16 at 09:29
  • Please include the output of `System.out.println(TimeZone.getDefault())` in all cases. – Andy Turner Dec 21 '16 at 09:39
  • @AndyTurner I've added what u wanted. – séan35 Dec 21 '16 at 10:34
  • 1
    Does [anything here](http://stackoverflow.com/questions/2493749/how-to-set-a-jvm-timezone-properly) help you? – Andy Turner Dec 21 '16 at 10:41
  • @AndyTurner It helps a lot, Andy. Thank u so much! – séan35 Dec 21 '16 at 14:42

1 Answers1

3

The latest changes related "Turkey switched from EET/EEST (+02/+03) to permanent +03" has not been integrated in JDK8 update 101 which you are using, infact it is not part of latest JDK 8 update 112. You need to manually upgrade the tzupgrader tool to get the changes in your JDK. Here is the "tzdata2016g" version that has the "Turkey switched from EET/EEST (+02/+03) to permanent +03" integrated, you can find more details here - http://www.oracle.com/technetwork/java/javase/tzdata-versions-138805.html You need to manually install tzupdator tool that you can get from here - http://www.oracle.com/technetwork/java/javase/tzupdater-readme-136440.html I hope that solves your problem.

Fairoz
  • 1,616
  • 13
  • 16