public static void main(String[] args) throws InterruptedException {
Date timestrat = new Date();
System.out.println(timestrat);
//睡眠5秒
Thread.sleep(5*1000);
Date timeend = new Date();
System.out.println(timeend);
//单位是毫秒
long miao = (timeend.getTime() - timestrat.getTime())/1000;
System.out.println(miao);
}
java 获取两个时间间隔多少秒
最新推荐文章于 2024-05-27 06:45:00 发布