以小时,分钟,秒,毫秒,微秒来获取时间 [英] Get time with hour, minute, second, millisecond, microsecond

查看:183
本文介绍了以小时,分钟,秒,毫秒,微秒来获取时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

SimpleDateFormat sDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

我知道这段代码返回时,分,秒。
我怎么也可以得到毫秒和毫秒?

I know that this code return hour, minute, second in the time. How i can get also the millisecond and microsecond??

推荐答案

您不会有毫秒,因为日期存储自1970年1月1日以来的毫秒数。对于毫秒,请使用 S ,如javadoc

You won't have microseconds, because a Date stores the number of milliseconds since Jan. 1 1970. For the milliseconds, use S, as documented in the javadoc.

这篇关于以小时,分钟,秒,毫秒,微秒来获取时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆