Search code examples
javatimezonelocalegeocoding

lon,lat to timezone


Does anyone know if there is any existing solution for determining a timezone from a point (lon, lat)?

i could hard code the few i need for this project but it'd be better to use a pre-built solution.

thanks.


Solution

  • Use a webservice such as the one provided by geonames.

    Example:

    http://api.geonames.org/timezone?lat=47.01&lng=10.2&username=demo
    

    Returns:

    ...
    <timezoneId>Europe/Vienna</timezoneId>
    ...