问题
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