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

前端 未结 5 1030
生来不讨喜
生来不讨喜 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条回答
  •  -上瘾入骨i
    2020-11-29 04:53

    Joda Time contains handling methods which will calculate the offsets for you. See DateTimeZone.convertLocalToUTC(...)

    To supplement this, you will need to look up the current time zone with your latitude/longitude info. GeoNames provides a java client for its web service, as well as a simple web-request framework (i.e. http://ws.geonames.org/timezone?lat=47.01&lng=10.2)

提交回复
热议问题