优化代码

This commit is contained in:
RuoYi
2023-02-21 18:02:00 +08:00
parent 1268637e58
commit 96ba768f50
30 changed files with 66 additions and 83 deletions

View File

@ -145,16 +145,20 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
}
/**
* 计算两个时间差
* 计算时间差(单位:分钟)
*
* @param endTime 最后时间
* @param startTime 开始时间
* @return 时间差(天/小时/分钟)
*/
public static String getDatePoor(Date endDate, Date nowDate)
public static String timeDistance(Date endDate, Date startTime)
{
long nd = 1000 * 24 * 60 * 60;
long nh = 1000 * 60 * 60;
long nm = 1000 * 60;
// long ns = 1000;
// 获得两个时间的毫秒时间差异
long diff = endDate.getTime() - nowDate.getTime();
long diff = endDate.getTime() - startTime.getTime();
// 计算差多少天
long day = diff / nd;
// 计算差多少小时