java – How to always get the correct time in a specific city (android / ios)?

Question:

I am writing an application for both platforms, in which it is vitally important to know the current exact time in a certain city, for example, Novosibirsk.

The time zone has recently changed, as well as the clock is set for winter and summer … In general, it is not always equal to GMT + 7. And you need to know exactly the correct time in the city, regardless of what is displayed on the user's device.

Are there any resources from which you can parse the exact time in a particular city or libraries with such a function …

In general, there is any single correct solution in this situation?

(android: I know how to use Jsoup, I parsed the time from http://www.epochconverter.com/ , but the site is sometimes unavailable, which means this option is not suitable)

I would be grateful for any useful information!

Answer:

I used google maps. Through the API https://maps.googleapis.com/maps/api/timezone/json, you can access the current time zone at the specified coordinates (including time translation). The coordinates of the city are easy to get from the name.

Here is the documentation:https://developers.google.com/maps/documentation/timezone/intro

Pay attention to the dstOffset and rawOffset parameters.

Scroll to Top