Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java, how to deactivate daylight saving?

Tags:

java

date

dst

Egypt has no more daylight saving, I'm making a web app in a server, and trying to change the time to Egypt time, it worked, but with daylight saving mode, how can I deactivate it!!

like image 679
AMTourky Avatar asked Sep 16 '26 01:09

AMTourky


1 Answers

You can't turn off daylight savings in the JVM. Each timezone is encoded with an offset and whether or not daylight savings time is applied (and if so, between what dates).

You can check this with:

TimeZone.getDefault().useDaylightTime();
TimeZone.getDefault().inDaylightTime( new Date() );

However, you can update your timezone files in your JDK installation with the TZUpdater tool:

http://www.oracle.com/technetwork/java/javase/downloads/tzupdater-download-513681.html

PS: Here's the revision of the timezone file where the change for egypt was introduced. There have since been 10 additional updates.

Version         JRE Versions Introduced   TzUpdaterVersion Description

tzdata2011g 1.4.2_33 5.0u31 6u26 7     1.3.39                   Change of DST rules for Egypt to abandon DST this year.

like image 62
Matt Avatar answered Sep 17 '26 14:09

Matt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!