Google Glass Time

假如想象 提交于 2019-12-08 13:43:03

问题


Is there a way to get the time in Google Glass pro grammatically? I am using System.currentTimeMillis(); but it gives me a really long number such as: 1403101657961. I want the actual time that the user is looking at when he turns on Glass. Thanks.


回答1:


All you need to do is create a Date object like so:

Date dt = new Date(System.currentTimeMillis());

If you want it as a formatted string you can take a look at SimpleDateFormat.




回答2:


You can use the class SimpleDateFormat to format your time to Date.

Create a date with your millisec :

Date date= new Date(System.currentTimeMillis());

then format it with SDF

new SimpleDateFormat(""yyyy.MM.dd G 'at' HH:mm:ss z").format(date)



来源:https://stackoverflow.com/questions/24288220/google-glass-time

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