private SimpleDateFormat dateformat; private long time; private long getMills(){ dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //时间格式 try { time = dateformat.parse("1971-01-01 00:00:00").getTime();//格式转换 System.out.println(time); } catch (java.text.ParseException e) { e.printStackTrace(); } return time; }
时间转换成毫秒值
最新推荐文章于 2025-10-17 09:12:09 发布
本文介绍了一个简单的Java程序,该程序使用SimpleDateFormat类将指定的日期时间字符串从“yyyy-MM-dd HH:mm:ss”格式解析为毫秒值。示例中解析的时间点为1971年1月1日午夜,并打印出了对应的时间戳。
2万+

被折叠的 条评论
为什么被折叠?



