Search code examples
javadatedst

Java, how to deactivate daylight saving?


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!!


Solution

  • 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.