1、计算相差多少天,多少小时,多少分,多少秒
long nd = 1000 * 24 * 60 * 60; //一天的毫秒数
long nh = 1000 * 60 * 60; //一小时的毫秒数
long nm = 1000 * 60; //一分钟的毫秒数
long ns = 1000; //一秒的毫秒数
Date nowDate = new Date();
// Timestamp nowTime = new Timestamp(nowDate.getTime());
String date = "2019-12-13 10:57:00";
Date beforeDate = dateFormatController.StrParseDate(date);
// 获得两个时间的毫秒时间差异
long diff = nowDate.getTime() - beforeDate.getTime();
// 计算差多少天
long day = diff / nd;
// 计算差多少小时
long hour = diff % nd / nh;
// 计算差多少分钟
long min = diff % nd % nh / nm;
// 计算差多少秒
long sec = diff / ns;
logger.info("----day="+day+"---hour="+hour+"---min="+min+"--sec="+sec);