When I use new Data().getTime(); with java in android, I can get the long value(13bits like 143XXXXX...XX), this value is determinded by the local time, when i change my android device local time, such as in advance or delay some hours, this value will be changed. How can I get the real unix timestamp disregard the local time and without using the network? thanks in advance!
System.currentTimeMillis()will get the UTC time for you just fine. If you're futzing with system clock inaccuracies (for example, setting your clock faster ten minutes or something), afaikSystem.currentTimeMillis()will increase by 10 minutes correspondingly. The only way to get an accurate time would be to get a response from a time server and check against that. I liketime.nist.govmyself.