-
Notifications
You must be signed in to change notification settings - Fork 5k
Description
Search before asking
- I had searched in the issues and found no similar issues.
What happened
In some parts of the project, org.apache.commons.lang3.time.DateUtils.addDays is used for day-based calculations. For example in BusinessTimeUtils:
businessDate = addDays(runTime, -1);
DateUtils.addDays performs time-based arithmetic, which may be affected by Daylight Saving Time (DST) transitions. In timezones such as America/Los_Angeles, DST changes can result in days with 23 or 25 hours, which may cause unexpected hour shifts when adding or subtracting days.
What you expected to happen
Day-based calculations should remain consistent regardless of DST transitions.
How to reproduce
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
ZonedDateTime laDateTime = ZonedDateTime.of(
2026, 3, 9,
2, 40, 58,
0,
ZoneId.of("America/Los_Angeles")
);
Date businessDate = Date.from(laDateTime.toInstant());
businessDate = addDays(businessDate, -1);
System.out.println(businessDate);
During DST transitions, the resulting time may shift unexpectedly because the calculation crosses a day with 23 hours.
Anything else
This behavior may affect other parts of the project that rely on DateUtils.addDays for day-based calculations.
So, a possible improvement could be to use date-based arithmetic (e.g., LocalDate.plusDays) in places where only the calendar date is required.
Version
dev
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct