根据已知假期列表,计算N个工作日之后是哪一天

HolidayVo where = new HolidayVo();
int guessHoliday = 0;
for (int i = 0; i < day / 5; i++) {
    guessHoliday += 2;
}
Date guessEnd = DateUtils.addDays(date, day + guessHoliday);
 
String startYear = DateFormatUtils.format(date, "yyyy");
String guessEndYear = DateFormatUtils.format(guessEnd, "yyyy");
boolean b = startYear.equalsIgnoreCase(
    guessEndYear);
where.setYear(startYear);
List < HolidayVo > allHoliday = null;
if (b) {
    allHoliday = this.getAllHoliday(where);
} else {
    allHoliday = new ArrayList < > ();
    for (int year = Integer.valueOf(startYear); year >= Integer.valueOf(guessEndYear); year++) {
        where.setYear(String.valueOf(year));
        allHoliday.addAll(this.getAllHoliday(where));
    }
}
Set < String > holidaySet = allHoliday.stream().map(Holiday::getDate).collect(Collectors.toSet());
int passWorkDay = 0;
Date testDate = date;
while (passWorkDay == day) {
    testDate = DateUtils.addDays(testDate, 1);
    if (!holidaySet.contains(DateFormatUtils.format(testDate, "yyyy-MM-dd"))) {
        passWorkDay++;
    }
}
return testDate;

 

Leave a Comment

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据