@Test
public void test23() throws ParseException {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date startTime = dateFormat.parse("2019-11-6 09:31:00");
Date endTime = dateFormat.parse("2019-11-6 09:32:00");
//单位是毫秒
long diff = endTime.getTime() - startTime.getTime();
long second = diff/1000;
System.out.println(second);
}
如何用Java实现计算两个时间之间有多少秒
最新推荐文章于 2022-06-02 17:58:18 发布