2013-11-20T17:42:55.7385459 如何在java中制作这种日期格式
我不知道这意味着什么,最后 7 个字符是什么.. yyyy-MM-dd'T'HH:mm:ss.7385459
请您参考如下方法:
看看here在System.nanoTime();
调用时,它提供纳秒级的精度(但不一定是纳秒级的精度)。 警告 作为一个例子,您可以尝试(但这可能是一个坏主意,因为 nanoTime()
不是为了获取挂钟时间) -
// It would probably be a better idea to use HH:mm:ss.SSS, and the nanoseconds.
// Not to imply that that's a good idea, just better then this (but would add even more digits).
private static final SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
// This isn't really nanosecond accurate, and is probably a bad idea.
private static String getNanoTime() {
long start = System.nanoTime();
StringBuilder sb = new StringBuilder();
Calendar c = Calendar.getInstance();
sb.append(sdf.format(c.getTime()));
sb.append(".");
sb.append(System.nanoTime() - start);
return sb.toString();
}
public static void main(String[] args) {
System.out.println(getNanoTime());
}