问题
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