Java tutorial · Intermediate · 14 min
Business days and day count conventions with Strata
A value date one day off means a failed settlement or wrong interest. Rather than recoding calendars and conventions, use Strata, OpenGamma's open-source Java library (Apache 2.0 licence) that implements them for rates and FX markets.
Tested source code, free to use: GitHub, Scopas-Team/java-finance-tutorials (Apache 2.0 licence)
The problem: java.time knows nothing about holidays
The first version people write often looks like this:
static LocalDate plusBusinessDays(LocalDate date, int days) {
while (days > 0) {
date = date.plusDays(1);
DayOfWeek d = date.getDayOfWeek();
if (d != DayOfWeek.SATURDAY && d != DayOfWeek.SUNDAY) days--;
}
return date;
}
It skips weekends but ignores 1 May, Christmas, 26 December, Good Friday and Easter Monday, the closing days of TARGET (the Eurosystem's payment system). Nor does it know that a EUR/USD trade must settle on a day that is a business day in both Frankfurt and New York. Calendars change every year: they are reference data, not code.
Installing Strata
Strata is split into modules: strata-basics (dates, calendars, conventions), then strata-product, strata-pricer and strata-measure for valuation. The first one is enough for this tutorial:
build.gradle
dependencies {
implementation "com.opengamma.strata:strata-basics:$strataVersion" // latest version on Maven Central
}
1. Calendars and business days
ReferenceData refData = ReferenceData.standard();
HolidayCalendar target = HolidayCalendarIds.EUTA.resolve(refData); // TARGET
HolidayCalendar paris = HolidayCalendarIds.FRPA.resolve(refData); // Paris
target.isHoliday(LocalDate.of(2026, 12, 25)); // true
target.isBusinessDay(LocalDate.of(2026, 12, 26)); // false: a Saturday, and closed anyway
target.next(LocalDate.of(2026, 12, 24)); // 2026-12-28: 25th and 26th closed, then Sunday
target.shift(LocalDate.of(2026, 12, 23), 2); // 2026-12-28: two business days later
ReferenceData is the entry point for all of Strata's reference data. The standard set covers the main financial centres; in production you can inject your own calendars, taken from the bank's reference data.
2. T+2 value dates and combined calendars
// Value date of a euro trade: two TARGET business days after the trade date
DaysAdjustment spotEur = DaysAdjustment.ofBusinessDays(2, HolidayCalendarIds.EUTA);
spotEur.adjust(LocalDate.of(2026, 12, 24), refData); // 2026-12-29
// EUR/USD FX: a business day for both TARGET and New York
HolidayCalendarId eurUsd = HolidayCalendarIds.EUTA.combinedWith(HolidayCalendarIds.USNY);
DaysAdjustment spotEurUsd = DaysAdjustment.ofBusinessDays(2, eurUsd);
Real market conventions are sometimes subtler (one calendar to count days, another to adjust the final date): Strata describes them with the variants of DaysAdjustment and with ready-made conventions per product.
3. Adjusting a date that falls on a closed day
BusinessDayAdjustment modFollowing =
BusinessDayAdjustment.of(BusinessDayConventions.MODIFIED_FOLLOWING, HolidayCalendarIds.EUTA);
// 31 January 2027 is a Sunday
modFollowing.adjust(LocalDate.of(2027, 1, 31), refData); // 2027-01-29
Following would give Monday 1 February, which changes month; Modified Following then goes back to the last business day of the month, Friday the 29th. It is the most common convention for swaps and loans.
4. Day counts: ACT/360, 30/360, ACT/365F
The year fraction (day count) drives the interest amount. For €1,000,000 at 3% from 15 January to 15 July 2026 (181 calendar days):
LocalDate start = LocalDate.of(2026, 1, 15);
LocalDate end = LocalDate.of(2026, 7, 15);
DayCounts.ACT_360.yearFraction(start, end); // 181/360 = 0.50278
DayCounts.THIRTY_E_360.yearFraction(start, end); // 180/360 = 0.5
DayCounts.ACT_365F.yearFraction(start, end); // 181/365 = 0.49589
| Day count | Typical use | Interest |
|---|---|---|
| ACT/360 | Euro money market, €STR, Euribor | €15,083.33 |
| 30E/360 | Fixed leg of euro swaps, bonds | €15,000.00 |
| ACT/365F | Sterling money market | €14,876.71 |
More than €200 apart on a single coupon: the day count is part of the contract. Strata returns the fraction as a double, which is standard for valuation; for an amount to be paid, convert to BigDecimal and round once at the end (see our tutorial on money in Java).
5. Generating a schedule
PeriodicSchedule definition = PeriodicSchedule.builder()
.startDate(LocalDate.of(2026, 1, 15))
.endDate(LocalDate.of(2028, 1, 15))
.frequency(Frequency.P6M)
.businessDayAdjustment(modFollowing)
.stubConvention(StubConvention.SHORT_INITIAL)
.build();
Schedule schedule = definition.createSchedule(refData);
for (SchedulePeriod p : schedule.getPeriods()) {
double fraction = p.yearFraction(DayCounts.THIRTY_E_360, schedule);
System.out.printf("%s -> %s: %.5f%n", p.getStartDate(), p.getEndDate(), fraction);
}
Strata separates unadjusted dates (used for 30/360 calculations) from adjusted dates (used for payment), handles irregular first or last periods (stubs) and roll conventions (end of month, IMM). All rules that are easy to forget when coding a schedule by hand.
Common pitfalls
- Mixing up the 30/360 variants: 30/360 ISDA, 30E/360 and 30E/360 ISDA treat month ends and February differently. Use exactly the one in the contract or confirmation.
- Calendars hard-coded: a new holiday or an exceptional closure must be taken into account without a release.
- Wrong calendar: a euro payment follows TARGET, not necessarily the local calendar; a multi-currency trade combines several calendars.
- No edge-case tests: test month ends, 29 February, Easter and year ends, with expected values supplied by the business.
Market conventions to make reliable?
Our consultants combine finance and Java and work on your rates, FX and back-office applications, on both the delivery and the business side.