开发者

simpledateformat to currenttimemillis-like format

Is there a way to bring back a date formatted with SimpleDateFormat to its long equivalent (like开发者_高级运维 System.currentTimeMillis())?


DateFormat format = new SimpleDateFormat("yyyy-MM-dd");

Date date = format.parse(VALUE).getTime();

Simplest way I can think of.


You could use SimpleDateFormat.parse() to get a Date object, and then call getTime() on that Date object.

That'll give you the number of milliseconds since January 1, 1970, 00:00:00 UTC (same as System.currentTimeMillis()).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜