【工具类】计算两个时间的差
This commit is contained in:
parent
e866ab8f27
commit
74b3cc43ac
|
@ -1,7 +1,6 @@
|
|||
package tqq9.lc123.cloud.app.plugin.operate.sys;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.metadata.dynamicobject.DynamicObjectType;
|
||||
import kd.bos.dataentity.utils.StringUtils;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.PreparePropertysEventArgs;
|
||||
|
@ -10,7 +9,6 @@ import kd.bos.logging.Log;
|
|||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import tqq9.lc123.cloud.app.plugin.operate.pm.RebateRulesReverPurOrderPlugin;
|
||||
import tqq9.lc123.cloud.app.plugin.utils.DateDifferenceCalculator;
|
||||
|
||||
import java.util.Date;
|
||||
|
@ -56,7 +54,7 @@ public class ValiddaysSavePlugin extends AbstractOperationServicePlugIn implemen
|
|||
for (DynamicObject dataEntity : dataEntities) {
|
||||
String dynamicObjectType = dataEntity.getDynamicObjectType().getName();
|
||||
Date currentDate = new Date();//当前日期
|
||||
Long remainingDays = null;
|
||||
int remainingDays = 0;
|
||||
if (StringUtils.equals(dynamicObjectType, "bd_supplier")) {
|
||||
//医疗器械生生产许可证
|
||||
Date tqq9_datefield1 = dataEntity.getDate("tqq9_datefield1");//失效日期
|
||||
|
|
|
@ -2,7 +2,6 @@ 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;
|
||||
|
@ -12,11 +11,11 @@ public class DateDifferenceCalculator {
|
|||
private final static Log logger = LogFactory.getLog(DateDifferenceCalculator.class);
|
||||
|
||||
// 计算两个日期之间的剩余天数
|
||||
public static long calculateRemainingDays(Date endDate, Date startDate) {
|
||||
public static int calculateRemainingDays(Date endDate, Date startDate) {
|
||||
// 将 Date 转换为 Instant 类型
|
||||
Instant endInstant = endDate.toInstant();
|
||||
Instant startInstant = startDate.toInstant();
|
||||
// 使用 ChronoUnit.DAYS 计算日期之间的天数
|
||||
return ChronoUnit.DAYS.between(startInstant,endInstant);
|
||||
return (int) ChronoUnit.DAYS.between(startInstant,endInstant);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue