问题
As the title says I need the current workd time in seconds since 1970.
This is what I've tried so far:
System.currentTimeMillis()
and
val df = DateFormat.getTimeInstance()
df.setTimeZone(TimeZone.getTimeZone("gmt"))
val gmtTime = df.format(Date())
But both are showing the time which is based on the phone time, so when a user changes the phone time manually it will be affected
Is there a way to get the current workd time in seconds without using an extern API?
回答1:
No, the only way to get time NOT based on device clock is to request it from some Web API service.
来源:https://stackoverflow.com/questions/54405146/android-kotlin-java-get-current-world-time-utc-in-seconds-since-1970