|
@@ -24,8 +24,8 @@ import org.springframework.web.bind.annotation.*;
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
-import java.time.Period;
|
|
|
|
import java.time.ZoneId;
|
|
import java.time.ZoneId;
|
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -144,20 +144,8 @@ public class ApiInterContriller {
|
|
// 将 Date 转换为 LocalDate
|
|
// 将 Date 转换为 LocalDate
|
|
LocalDate startLocalDate = startDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
LocalDate startLocalDate = startDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
LocalDate endLocalDate = endDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
LocalDate endLocalDate = endDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
-
|
|
|
|
- // 使用 Period 类来计算日期差异
|
|
|
|
- Period period = Period.between(startLocalDate, endLocalDate);
|
|
|
|
-
|
|
|
|
- // 如果年差异大于 0 或月差异大于 1,则认为超过一个月
|
|
|
|
- if (period.getYears() > 0 || period.getMonths() > 1) {
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 如果月差异是 1,检查天数是否足够达到一个月
|
|
|
|
- if (period.getMonths() == 1 && period.getDays() >= 0) {
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return false;
|
|
|
|
|
|
+ // 计算两个日期之间的天数差
|
|
|
|
+ long daysBetween = ChronoUnit.DAYS.between(startLocalDate, endLocalDate);
|
|
|
|
+ return daysBetween > 31;
|
|
}
|
|
}
|
|
}
|
|
}
|