Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Location based Timezone Retrieval

Tags:

java

timezone

Given: LDAP stores location of users.

How do I drive their timezones using their location? Any pointers are accepted, Java language preferred.

Thanks in advance.

like image 885
samsina Avatar asked Mar 09 '10 01:03

samsina


People also ask

How do you find the timezone using latitude and longitude?

Here's how longitude converts into your personal time zone: 15 degrees of longitude = 1 hour difference; 1 degree longitude = 4 minutes difference. 15 minutes of longitude = 1 minute difference; 1 minute of longitude = 4 seconds difference.

How do I find the offset of time zones?

You can get the offset of a timezone using ZonedDateTime#getOffset . Note that the offset of a timezone that observes DST changes as per the changes in DST. For other places (e.g. India), it remains fixed. Therefore, it is recommended to mention the moment when the offset of a timezone is shown.

Are time zones based on longitude?

Time zones are another arbitrary societal choice, like the origin point of the Prime Meridian. They are based on longitude and defined by Earth's rotation, which completes a full circle (360 degrees) each day (24 hours). Each hour then, Earth rotates through 360/24 = 15° of longitude: the width of one time zone.


1 Answers

This depends on information the "location" contains? You'd somehow need to map the location to a timezone name, preferably the Olson style timezone names, because they are more detailed and easier to map, as they are locations themselves.

If it's an approximate addres (like country and city or so) then several geolocation services do include timezones in their information, so you can call these services and see.

If it's a geolocation with latitude and longitude then a site called Earthtools can give you the timezone. http://www.earthtools.org/webservices.htm#timezone

There is this database that provides mappings from cities and countries to timezones: http://citytimezones.info/cms/pending_requests.htm

Unfortunately it uses Windows timezone names, but you can this data http://unicode.org/repos/cldr/trunk/common/supplemental/windowsZones.xml from Unicode.org to map between Windows timezone names and the Olson TZ names.

like image 188
Lennart Regebro Avatar answered Sep 21 '22 13:09

Lennart Regebro