Can anyone help with the following problem?
My operating system is latest windows 10 and its time zone is
(UTC+0300) Istanbul(Daylight saving has been removed and time zone was set to+0300after the last regulations in Turkey - 7 September 2016)I am using latest JDK which is 1.8.0_131. Tzdata version of this JDK is tzdata2017a which includes time zone changes for Turkey.
This is tiny part of my application that I implemented in main method:
import java.util.Date;
import java.util.TimeZone;
public class TestMain {
public static void main(String[] args) {
String timeZoneStr = "Asia/Istanbul";
TimeZone timeZone = TimeZone.getTimeZone(timeZoneStr);
Date localDate = new Date();
System.out.println(localDate);
localDate.setTime(155631515L);
System.out.println(localDate);
System.out.println(getUTCFromLocal(localDate, timeZone));
}
public static Date getUTCFromLocal(Date localDate, TimeZone localTimeZone) {
return new Date(localDate.getTime()-localTimeZone.getOffset(localDate.getTime()));
}
}
Result of the code is :
Sun May 21 15:19:48 EET 2017
Fri Jan 02 21:13:51 EET 1970
Fri Jan 02 19:13:51 EET 1970
According to latest time zone update, last line of output should be "Fri Jan 02 18:13:51 EET 1970", not "Fri Jan 02 19:13:51 EET 1970".
In additon to this, when I create new date object (new java.util.Date()), the information in that object seems correct and time zone on +0300, but if I use setTime method of Date object time zone information changes to +0200.
When date object created with new java.util.Date():
When localDate.setTime(155631515L) method executed:
I also reproduced same issue on other JDK versions.

