Convert elapsed real time to Date

对着背影说爱祢 提交于 2019-12-06 00:02:32

Found a solution to the problem:

new Date(System.currentTimeMillis() 
       - SystemClock.elapsedRealtime()
       + elapsedTime);

where elapsedTime is the time I receive from Android. As far as I've tested, this seems to return the correct date/time for an elapsed time. I'm just not very fond of this answer because Google warns not to use System.currentTimeMillis(). Unless someone has a better answer, I'm closing this question as answered.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!