/**
*
* 计算两段时间的小时差
* @module
* @author SJT
* @date 2022/12/28
* @param startTime
* @param endTime
* @return: java.lang.Integer
*/
public static Integer calculateHourDiff(String startTime,String endTime) {
try {
SimpleDateFormat simpleFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
long from = simpleFormat.parse(startTime).getTime();
long to = simpleFormat.parse(endTime).getTime();
Integer hours = (int) ((to - from)/(1000 * 60 * 60*1.0));
return hours;
}catch (Exception e) {
e.printStackTrace();
return 0;
}
}
知是行之始,行是知之成!