System.currentTimeMillis(); If I change system tim

2019-06-16 08:56发布

If I use System.currentTimeMillis() at 00:00 and I get X value.

Then I set the clock back one hour, and after one hour i call System.currentTimeMillis().

Will it return X again, or will it just be X + 3600 * 1000

标签: java time
3条回答
再贱就再见
2楼-- · 2019-06-16 09:30

In a nutshell, whenever you change system time, the value returned by System.currentTimeMillis() will change accordingly.

This is in contrast to System.nanoTime().

查看更多
对你真心纯属浪费
3楼-- · 2019-06-16 09:34

On Android, you can always use SystemClock.elapsedRealtime().

查看更多
你好瞎i
4楼-- · 2019-06-16 09:53

It will return X because System.currentTimeMillis() returns the number of milliseconds since the epoch. That means it will be insynch with your clock and count the number of seconds since January 1, 1970 UTC

查看更多
登录 后发表回答