Determine Whether Daylight Savings Time (DST) is Active in Java for a Specified Date

前端 未结 5 1047
生来不讨喜
生来不讨喜 2020-11-29 04:29

I have a Java class that takes in the latitude/longitude of a location and returns the GMT offset when daylight savings time is on and off. I am looking for an easy way to

5条回答
  •  星月不相逢
    2020-11-29 05:00

    You're going to have to do a bit more work using those coordinates and figure out which time zone they're in. Once you know which TimeZone that is, the isDayLight() method would be useful.

    For example, you have no way of telling whether -0500 is EST (US/Canada Eastern Standard Time), CDT (US/Canada Central Daylight Time), COT (Colombia Time), AST (Brazil Acre Standard Time), ECT (Ecuador Time), etc...

    Some of these may or may not support daylight saving time.

提交回复
热议问题