0

I know about such method:

System.currentTimeMillis() / 1000

which return seconds since epoch. BUT it depends on time on device. Maybe smb know about getting timestamp without connection with device time? For example when I change time at device/emulator the total number of seconds since epoch changes too, and logic of my program crashes.

Andrew
  • 1,947
  • 2
  • 23
  • 61
  • `and logic of my program crashes.` if your app stability relies on the epoch then I highly recommend you fix that first... – Zun Mar 13 '19 at 10:22
  • @ZUNJAE, what do you think about ntp server? – Andrew Mar 13 '19 at 10:31
  • Possible duplicate of [How to use an Internet time server to get the time?](https://stackoverflow.com/questions/4442192/how-to-use-an-internet-time-server-to-get-the-time). And/or of [How to get current time from internet in android](https://stackoverflow.com/questions/13064750/how-to-get-current-time-from-internet-in-android). – Ole V.V. Mar 15 '19 at 10:48

1 Answers1

1

If you want to get internet time instead of device time use truetime

PS: it was little slow for me to connect, but did work

Vinil Prabhu
  • 1,279
  • 1
  • 10
  • 22
  • I have already found this library but I can't use it due to difficulties with using at my project ;( – Andrew Mar 13 '19 at 12:06