[英]Does anyone know how to get the local date and time from Android 2.1 device?
Does anyone know know how to programatically get the local date and time of the Android device? 有谁知道如何以编程方式获取Android设备的本地日期和时间? With that local date and time, does anyone know how to convert that to milliseconds from 1970 in UTC time?
使用该本地日期和时间,有谁知道如何将其转换为UTC时间中的1970年的毫秒数?
These are just standard Java solutions; 这些只是标准的Java解决方案。 nothing unique to Android:
Android独有的功能:
// Get the local date/time
Calendar now = Calendar.getInstance();
// Return milliseconds from 1970 UTC
long milliseconds = now.getTimeInMillis();
Another shorter way, if you just want the current timestamp in millis. 如果您只想以毫秒为单位的当前时间戳,则是另一种较短的方法。
long now = System.currentTimeMillis();
很久以前= System.currentTimeMillis();
http://developer.android.com/reference/java/lang/System.html#currentTimeMillis%28%29 http://developer.android.com/reference/java/lang/System.html#currentTimeMillis%28%29
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.