如何在格式化的日期字符串中包含毫秒? [英] How to include milliseconds in a formatted date string?
本文介绍了如何在格式化的日期字符串中包含毫秒?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我正在编码以下内容:
Hi I am coding the following:
String sph=(String) android.text.format.DateFormat.format("yyyy-MM-dd_hh-mm-ss_SSS", new java.util.Date());
我想要当前的日期和时间以及毫秒
I want the current date and time and milliseconds
它给我的是:
2011-09-01_09-55-03-SSS
SSS没有转换回毫秒...
The SSS is not converting back to milliseconds...
任何人都知道为什么以及什么应该让毫秒在3位?
Does anyone know why and what should it be to get the milliseconds in 3 position?
谢谢
推荐答案
使用以下内容:
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss_SSS");
String dateString = formatter.format(new java.util.Date());
这篇关于如何在格式化的日期字符串中包含毫秒?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文