22 lines
		
	
	
		
			738 B
		
	
	
	
		
			Java
		
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			738 B
		
	
	
	
		
			Java
		
	
	
	
package tqq9.lc123.cloud.app.plugin.utils;
 | 
						|
 | 
						|
import kd.bos.logging.Log;
 | 
						|
import kd.bos.logging.LogFactory;
 | 
						|
 | 
						|
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 int calculateRemainingDays(Date endDate, Date startDate) {
 | 
						|
        // 将 Date 转换为 Instant 类型
 | 
						|
        Instant endInstant = endDate.toInstant();
 | 
						|
        Instant startInstant = startDate.toInstant();
 | 
						|
        // 使用 ChronoUnit.DAYS 计算日期之间的天数
 | 
						|
        return (int) ChronoUnit.DAYS.between(startInstant,endInstant);
 | 
						|
    }
 | 
						|
}
 |