public static void main(String[] args) throws ParseException {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String oldDateStr = "2021-12-23 10:10:10";
long time = format.parse(oldDateStr).getTime();
long nd = 1000 * 24 * 60 * 60;//每天毫秒数
long diff = new Date().getTime()-time;
long day = diff / nd;
System.out.println(day);
}
计算两个时间相差几天
最新推荐文章于 2024-06-30 03:36:02 发布