Java has no single method for the business days between two dates, so we stream every date with LocalDate.datesUntil(), filter out weekend days and holidays, and count what is left. The method datesUntil() excludes the end date, so for an inclusive range we pass end.plusDays(1).
We count business days for leave requests, SLA reports, invoice terms such as “net 10 business days” and project plans. The same stream also returns the list of the business dates when we need them, for example to book a resource on each day.
The following example counts the business days in October 2026, once without a holiday and once with a holiday on October 12. The isBusinessDay() method is defined in section 1.
LocalDate first = LocalDate.of(2026, 10, 1);
LocalDate last = LocalDate.of(2026, 10, 31);
long workdays = first.datesUntil(last.plusDays(1)).filter(d -> isBusinessDay(d, Set.of())).count(); // 22
Set<LocalDate> holidays = Set.of(LocalDate.of(2026, 10, 12));
long afterHoliday = first.datesUntil(last.plusDays(1)).filter(d -> isBusinessDay(d, holidays)).count(); // 21
Notice the plusDays(1), which makes October 31 part of the range. We start with the inclusive and exclusive end, and we also cover the list of dates, a week-based formula for long ranges and a leave-request example.
1. Counting Business Days with datesUntil()
The method datesUntil(endExclusive), added in Java 9, returns a Stream<LocalDate> with every date from the start date up to the day before the end date. We filter that stream with a business-day check, which tests the day of the week and looks the date up in a holiday Set.
static boolean isBusinessDay(LocalDate date, Set<LocalDate> holidays) {
DayOfWeek day = date.getDayOfWeek();
return day != DayOfWeek.SATURDAY && day != DayOfWeek.SUNDAY && !holidays.contains(date);
}
static long countBusinessDays(LocalDate start, LocalDate endInclusive, Set<LocalDate> holidays) {
return start.datesUntil(endInclusive.plusDays(1))
.filter(date -> isBusinessDay(date, holidays))
.count();
}
A Set is the right type for the holidays, because HashSet.contains() takes constant time, whereas List.contains() scans the whole list for every date. The datesUntil() article shows the stream method with a step Period as well.
2. Inclusive or Exclusive End Date
Decide first whether the end date belongs to the range, because the two answers differ by one whenever the end date is a business day. A leave request from Monday to Friday is five days, so it includes the end date. A due-date calculation that asks how many business days are left until a deadline excludes it in most apps.

| Call | Range | Result for Oct 5 to Oct 16, 2026 with Oct 12 as a holiday |
|---|---|---|
| start.datesUntil(end) | Start included, end excluded | 8 business days |
| start.datesUntil(end.plusDays(1)) | Both included | 9 business days |
| start.plusDays(1).datesUntil(end) | Both excluded | 7 business days |
| ChronoUnit.DAYS.between(start, end) | All calendar days, end excluded | 11 days |
LocalDate sprintStart = LocalDate.of(2026, 10, 5);
LocalDate sprintEnd = LocalDate.of(2026, 10, 16);
Set<LocalDate> octoberHoliday = Set.of(LocalDate.of(2026, 10, 12));
long exclusive = sprintStart.datesUntil(sprintEnd).filter(d -> isBusinessDay(d, octoberHoliday)).count(); // 8
long inclusive = countBusinessDays(sprintStart, sprintEnd, octoberHoliday); // 9
long bothExcluded = sprintStart.plusDays(1).datesUntil(sprintEnd).filter(d -> isBusinessDay(d, octoberHoliday)).count(); // 7
long calendarDays = ChronoUnit.DAYS.between(sprintStart, sprintEnd); // 11
When the start date is after the end date, datesUntil() throws an IllegalArgumentException instead of returning a negative count. We either swap the dates or reject the input with a clear message before calling it.
long reversed = LocalDate.of(2026, 10, 16).datesUntil(LocalDate.of(2026, 10, 5)).count(); // IllegalArgumentException: 2026-10-05 < 2026-10-16
3. Getting the List of Business Days
The count answers “how many”, but scheduling code often needs the dates themselves. The same stream ends with toList() instead of count(), which returns an unmodifiable list on Java 16 and later.
static List<LocalDate> businessDaysBetween(LocalDate start, LocalDate endInclusive, Set<LocalDate> holidays) {
return start.datesUntil(endInclusive.plusDays(1))
.filter(date -> isBusinessDay(date, holidays))
.toList();
}
List<LocalDate> week = businessDaysBetween(LocalDate.of(2026, 10, 9), LocalDate.of(2026, 10, 14), Set.of(LocalDate.of(2026, 10, 12))); // [2026-10-09, 2026-10-13, 2026-10-14]
int size = week.size(); // 3
4. Counting Weekdays With Week Arithmetic
The stream touches every date, so a range of ten years means about 3,650 checks. For reports that count many long ranges, we compute whole weeks with arithmetic, because every 7 consecutive days hold 5 weekdays, and check only the 0 to 6 leftover days one by one. Holidays are subtracted afterwards, counting only those that fall on a weekday inside the range.
static long countWeekdays(LocalDate start, LocalDate endExclusive) {
long days = ChronoUnit.DAYS.between(start, endExclusive);
if (days < 0) {
throw new IllegalArgumentException(start + " is after " + endExclusive);
}
long count = days / 7 * 5;
for (LocalDate d = start.plusDays(days / 7 * 7); d.isBefore(endExclusive); d = d.plusDays(1)) {
if (isBusinessDay(d, Set.of())) {
count++;
}
}
return count;
}
static long countBusinessDaysFast(LocalDate start, LocalDate endExclusive, Set<LocalDate> holidays) {
long holidaysOnWeekdays = holidays.stream()
.filter(h -> !h.isBefore(start) && h.isBefore(endExclusive) && isBusinessDay(h, Set.of()))
.count();
return countWeekdays(start, endExclusive) - holidaysOnWeekdays;
}
LocalDate from = LocalDate.of(2026, 1, 1);
long tenYears = countWeekdays(from, LocalDate.of(2036, 1, 1)); // 2608
long fastOctober = countBusinessDaysFast(LocalDate.of(2026, 10, 1), LocalDate.of(2026, 11, 1), Set.of(LocalDate.of(2026, 10, 12))); // 21
boolean matchesStream = IntStream.range(0, 400).allMatch(n -> countWeekdays(from, from.plusDays(n)) == from.datesUntil(from.plusDays(n)).filter(d -> isBusinessDay(d, Set.of())).count()); // true
The last line compares the formula with the stream for 400 different range lengths. Weekday formulas often go wrong by one at the ends of the range, so a check like this one belongs in the unit tests of any formula we write or copy.
5. Counting Leave Days in an HR App
Say an employee requests leave from Friday, October 9 to Tuesday, October 13, 2026, and October 12 is a company holiday. The HR app must deduct only the days the employee would have worked, so the range is inclusive and both the weekend and the holiday are excluded.
LocalDate leaveFrom = LocalDate.of(2026, 10, 9);
LocalDate leaveTo = LocalDate.of(2026, 10, 13);
Set<LocalDate> companyHolidays = Set.of(LocalDate.of(2026, 10, 12));
long leaveDays = countBusinessDays(leaveFrom, leaveTo, companyHolidays); // 2
List<LocalDate> absentOn = businessDaysBetween(leaveFrom, leaveTo, companyHolidays); // [2026-10-09, 2026-10-13]
The calendar span is five days, but the app deducts two leave days and books the absence on those two dates in the team calendar. In a real app, the holiday set comes from a table keyed by country or office, because a company with offices in several countries has several holiday calendars.
6. Business Days Between Two Dates in Java FAQs
Holidays, inclusive end dates and other weekend rules change the working-day count.
6.1. Does ChronoUnit.DAYS.between() skip weekends?
No. The method ChronoUnit.DAYS.between() counts calendar days, weekends included, and excludes the end date. For business days, we filter the dates as shown in section 1.
6.2. How do we count business days when the weekend is Friday and Saturday?
We replace the hard-coded check with a Set<DayOfWeek> parameter, for example EnumSet.of(DayOfWeek.FRIDAY, DayOfWeek.SATURDAY), and test !weekend.contains(date.getDayOfWeek()). The rest of the stream stays the same.
6.3. How do we add a number of business days to a date instead of counting them?
We loop with plusDays(1) and decrement a counter on each business day. The add or subtract business days article has a method that handles negative numbers too.
6.4. How do we count the days between two dates, weekends included?
We use ChronoUnit.DAYS.between(start, end), or Period.between() for years, months and days. The days between two dates article compares both.
7. Conclusion
Counting business days in Java is a stream over datesUntil() with a filter for weekend days and holidays, and toList() returns the dates themselves. The end date is excluded by datesUntil(), so an inclusive range needs end.plusDays(1), and a start date after the end throws IllegalArgumentException.
For long ranges, whole weeks contribute five weekdays each, so a short loop over the leftover days and a holiday subtraction give the same count without visiting every date. More date arithmetic, such as adding months or finding the last day of a month, is collected in the Java date and time guide.
8. References
- LocalDate.datesUntil() (Java SE 25 API)
- ChronoUnit (Java SE 25 API)
- DayOfWeek (Java SE 25 API)
- Stream.toList() (Java SE 25 API)
Happy Learning !!
plusDays? where is the ref for it?
LocalDate.html#plusDays(long)
The above logic does not consider the last date i.e. endDate value even if its not in holiday list or is a weekend
Right. The end date is exclusive.