Java: Calculating time zone difference

dst, java, timezone

Solution

Use TimeZone.getRawOffset(): Returns the amount of time in milliseconds to add to UTC to get standard time in this time zone. Because this value is not affected by daylight saving time, it is called raw offset.

If you want the offset including DST then you use TimeZone.getOffset(long date). You should provide the concrete date to the method, eg now - System.currentTimeMillis()

Problem

How do I get the time difference from GMT for a specific date and time zone in Java? Determining whether a specific time zone is in DST is quite straight-forward: ``` boolean isIsraelInDST = TimeZone.getTimeZone("Israel").inDaylightTime(new Date()); ``` How do I get the actual time difference?

Original source

Related problems