|
@@ -7,6 +7,8 @@ import java.lang.management.ManagementFactory;
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.time.*;
|
|
import java.time.*;
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
import java.util.Calendar;
|
|
import java.util.Calendar;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
|
|
@@ -157,6 +159,21 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
|
return day + "天" + hour + "小时" + min + "分钟";
|
|
return day + "天" + hour + "小时" + min + "分钟";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static long getDaysDiff(String start, String end)
|
|
|
|
+ {
|
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
|
|
+
|
|
|
|
+ // 解析字符串为LocalDate对象
|
|
|
|
+ LocalDate startDate = LocalDate.parse(start, formatter);
|
|
|
|
+ LocalDate endDate = LocalDate.parse(end, formatter);
|
|
|
|
+
|
|
|
|
+ // 计算两个日期之间的天数差
|
|
|
|
+ return ChronoUnit.DAYS.between(startDate, endDate);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
/** 计算两个时间差,返回是否大于一个月 */
|
|
/** 计算两个时间差,返回是否大于一个月 */
|
|
public static boolean isMoreThanOneMonth(String startDateStr, String endDateStr) throws ParseException {
|
|
public static boolean isMoreThanOneMonth(String startDateStr, String endDateStr) throws ParseException {
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|