开发者

simpledateformat to currenttimemillis-like format

开发者 https://www.devze.com 2023-04-12 08:45 出处:网络
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\");

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

精彩评论

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

关注公众号