开发者

Calculate business days difference between two days excluding holidays?

I already have a list of holidays which is a List .

Given two Date object, how could I calcul开发者_开发技巧ate the difference in working days (not counting weekends and holidays) between them?

I have found the library ObjectLab Kit but I think it only knows how to advance days.

Thanks


I found Jollyday useful in earlier projects.


Probably not the most efficient way, but probably fast enough: loop starting with the earliest date, add a day at each iteration until the end date, and increment a counter unless the current day is a weekend or a holiday.

java.util.Calendar is the class to use. It has method to add a day to itself and check if it's a saturday or a sunday.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜