Android how to get device's time not timezone time

寵の児 提交于 2020-01-05 08:29:55

问题


My case is: user set timezone to UTC+5, for example, and then turn off time and timezone sync. When he goes to UTC+4 timezone, he just set the time back to an hour, without touching timezone.

So the Calendar.getInstance() and System.currentTimeMillis() return the time for UTC+5, for example, 14:00, but the device shows 13:00.

How can I get the device time(13:00) or difference between device time and current timezone time?


回答1:


All that I could find, kept here in this post.

Summary: it is impossible to obtain the necessary time difference with no additional queries to the server and / or receiving your own coordinates (which may not always be available).

This also applies to canceled daylight time: some devices still believes that in the summer time zone of Moscow is GMT+4, other part knows that it's GMT+3. And you can not locally sync these devices locally, in general.



来源:https://stackoverflow.com/questions/31776435/android-how-to-get-devices-time-not-timezone-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!