23 lines
788 B
Java
23 lines
788 B
Java
package tqq9.lc123.cloud.app.plugin.utils;
|
|
|
|
import kd.bos.logging.Log;
|
|
import kd.bos.logging.LogFactory;
|
|
import tqq9.lc123.cloud.app.plugin.task.DaysRemaining;
|
|
|
|
import java.time.Instant;
|
|
import java.time.temporal.ChronoUnit;
|
|
import java.util.Date;
|
|
|
|
public class DateDifferenceCalculator {
|
|
private final static Log logger = LogFactory.getLog(DateDifferenceCalculator.class);
|
|
|
|
// 计算两个日期之间的剩余天数
|
|
public static long calculateRemainingDays(Date endDate, Date startDate) {
|
|
// 将 Date 转换为 Instant 类型
|
|
Instant endInstant = endDate.toInstant();
|
|
Instant startInstant = startDate.toInstant();
|
|
// 使用 ChronoUnit.DAYS 计算日期之间的天数
|
|
return ChronoUnit.DAYS.between(startInstant,endInstant);
|
|
}
|
|
}
|