How to get the real time UTC, regardless of device Time (not Time Zone)

Is there a way in Android to get the current timestamp, regardless of the time set in the device settings?

I have no problem with timeoffset that does not match time zones. My problem is that if I set the wrong time in the settings of my device, then the time stamp that I get from the System is based on this wrong time.

Current UTC 1447164873 10.11.2015 14:14:33and 15:14:33Local timestamp (my time zone is +1: 00)

if i call System.currentTimeMillis() /1000i get rightTimestamp = 1447164873;

if I go to the device settings and set the time of my device one hour ahead (16:14:33), it System.currentTimeMillis()/1000returns the wrong one Timestamp = 1447168473, which is 15:14:33also 16:14:33local.

Is it possible to get a real UTC timestamp, regardless of the time set on my device?

+4
source share

Source: https://habr.com/ru/post/1615257/


All Articles