Java 在android中以毫秒为单位获取系统时间
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18844331/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Get System time in Milliseconds in android
提问by NitZRobotKoder
Want to get time in milliseconds in android Ex 19:57:21:522.How do i do this?Could not find any straight forward API's to do so.
想要在 android Ex 19:57:21:522 中获得以毫秒为单位的时间。我该怎么做?找不到任何直接的 API 来这样做。
采纳答案by Scary Wombat
Try SimpleDateFormat
尝试 SimpleDateFormat
http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
Use a pattern with a capital S
使用带有大写 S 的模式
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
String currentDateandTime = sdf.format(new Date());