Skip to content

[Bug] [dolphinscheduler-common] DST issue when using DateUtils.addDays in BusinessTimeUtils #18048

@iampratap7997-dot

Description

@iampratap7997-dot

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

Metadata

Metadata

Labels

backendbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions