Quick revision
The short answer
plusHours(24) adds 24 hours of real elapsed time on the timeline, and the day DST ends is 25 hours long, so after 24 hours the local clock shows 01:00, not 02:00. plusDays(1) adds one calendar day and keeps the local time where it exists, which is what a daily 02:00 job wants. The rule is to choose by intent: elapsed time uses Duration and hours, same wall-clock time uses days or Period, and scheduler cron expressions with a zone handle this but need their gap and overlap behaviour checked.
What to remember
In this answer, we saw that the day DST ends is 25 hours long, so plusHours(24) on a ZonedDateTime, which adds elapsed time on the instant timeline, lands at 01:00 local time. plusDays(1) adds a calendar day on the local timeline and keeps 02:00. The fix is to choose by intent: Duration and hours for elapsed time, days or Period for the same wall-clock time. Cron schedulers with a zone keep wall-clock times, but their behaviour in gaps and overlaps must be checked and tested.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
plusHours(24) adds 24 hours of real elapsed time on the timeline, and the day DST ends is 25 hours long, so after 24 hours the local clock shows 01:00, not 02:00. plusDays(1) adds one calendar day and keeps the local time where it exists, which is what a daily 02:00 job wants. The rule is to choose by intent: elapsed time uses Duration and hours, same wall-clock time uses days or Period, and scheduler cron expressions with a zone handle this but need their gap and overlap behaviour checked.
Why this question is asked
Jobs that drift by an hour twice a year are a classic production surprise, because they only fail on two nights and the code looks obviously right. Interviewers ask this to find out whether we understand that 'a day' means two different things: 24 hours of elapsed time, or one step on the calendar. In this answer, we will recap what happens to the clock when DST ends, reproduce the drift, explain why plusHours and plusDays disagree, fix the code by intent, and then look at how cron-based schedulers handle the same nights.
1A Quick Recap: The Day DST Ends
In America/New_York, daylight saving time ended on 2 November 2025. At 02:00 local time, clocks went back to 01:00, and the offset from UTC changed from -04:00 to -05:00. So the hour from 01:00 to 02:00 happened twice that night, and the calendar day of 2 November was 25 hours long.
A ZonedDateTime, a date and time tied to a region such as America/New_York, knows these rules. That is useful, but it also means we have to tell it what we mean by 'add a day'.
2Reproducing the Drift
Our job last ran at 02:00 on 1 November, and computes its next run time by adding 24 hours.
Notice that the two results differ by exactly the hour the clocks went back. plusHours(24) landed at 01:00 local time, which is the drift in the question. plusDays(1) landed at 02:00, the time the job is supposed to run. And since each run computes the next one from the previous result, the job stays at 01:00 from then on, until the spring change pushes it back.
3Why plusHours and plusDays Disagree
plusHours works on the instant timeline. Java converts the ZonedDateTime to its instant, adds 24 times 3600 seconds, and converts back to local time with the zone rules. Because 2 November had 25 hours, 24 hours after 02:00 on 1 November is one hour before 02:00 on 2 November: 01:00 in the second, winter-time pass through that hour.
plusDays works on the local timeline. Java adds one to the date and keeps the local time 02:00, then resolves that local date-time in the zone. 02:00 on 2 November exists exactly once (the clocks went back at 02:00, so the repeated hour is 01:00 to 01:59), so the result is 02:00-05:00. If the local time had fallen into a gap or an overlap, Java would apply its usual resolution: move forward out of a gap, and keep the previous offset in an overlap if it is still valid.
| Operation | Works on | Result from 2025-11-01 02:00 | Elapsed time |
|---|---|---|---|
plusHours(24) | instant timeline | 2025-11-02 01:00 -05:00 | 24 h |
plus(Duration.ofDays(1)) | instant timeline | 2025-11-02 01:00 -05:00 | 24 h |
plusDays(1) | local timeline | 2025-11-02 02:00 -05:00 | 25 h |
plus(Period.ofDays(1)) | local timeline | 2025-11-02 02:00 -05:00 | 25 h |
4Fix: Choose by Intent
The fix is not 'always use plusDays'. It is to ask what the code means. A daily job, a reminder at 9 every morning or a store opening time mean the same wall-clock time each day, so they use plusDays or a Period, which counts calendar days, months and years. A token that expires 24 hours after issue, a lock timeout or a rate limit window mean an exact amount of elapsed time, so they use plusHours or a Duration, which counts seconds.
Notice that for the token we use Instant rather than ZonedDateTime. Elapsed time has nothing to do with local clocks, and working on Instant makes that obvious to the reader. A good habit is to compute the next run from the schedule rule itself, for example 'today's date in the zone at 02:00', instead of from the previous run, so one bad calculation does not carry forward forever.
5What Cron Schedulers Do on These Nights
Most applications do not compute next run times by hand; they use a scheduler. Spring's @Scheduled with a cron expression and a zone attribute, or Quartz's CronTrigger with a time zone, think in wall-clock terms, so a job at 02:00 in America/New_York stays at 02:00 across the change. That solves our problem.
But there is a catch. On the spring night, 02:00 to 02:59 does not exist, so a job set for 02:30 has no matching wall-clock time. On the autumn night, a job set for 01:30 matches twice. Schedulers differ in what they do, skipping, shifting or running twice, and the behaviour has changed between versions, so check your version and test those two nights. If neither behaviour is acceptable, the simplest fix is to schedule outside the 01:00 to 03:00 window, or to schedule in UTC for jobs that do not need local time at all.
6Follow-up questions
Is Duration.ofDays(1) the same as Period.ofDays(1)?
No. Duration.ofDays(1) is exactly 24 hours of elapsed time, so it behaves like plusHours(24) and drifts across DST. Period.ofDays(1) is one calendar day, so it behaves like plusDays(1) and keeps the local time.
Would the job have been fine if the server ran in UTC?
If the job were scheduled in UTC, it would run at 02:00 UTC every day with no drift, but that is 21:00 or 22:00 in New York depending on the season. Whether that is fine depends on the requirement. If the business wants 02:00 New York time, UTC scheduling simply moves the drift into local time.
How would you test this?
Use a fixed Clock or explicit ZonedDateTime values on both DST nights, 9 March and 2 November 2025 in America/New_York, and assert the next run is at 02:00 local time. For the scheduler, test the next execution times of the cron expression around those dates, since the scheduler's behaviour is what actually runs in production.
7Conclusion
In this answer, we saw that the day DST ends is 25 hours long, so plusHours(24) on a ZonedDateTime, which adds elapsed time on the instant timeline, lands at 01:00 local time. plusDays(1) adds a calendar day on the local timeline and keeps 02:00. The fix is to choose by intent: Duration and hours for elapsed time, days or Period for the same wall-clock time. Cron schedulers with a zone keep wall-clock times, but their behaviour in gaps and overlaps must be checked and tested.
Open with
plusHours adds exact elapsed time. Java converts the ZonedDateTime to an instant, adds 86,400 seconds and converts back. On the day DST ends the local day is 25 hours long, because the clocks go back from 02:00 to 01:00, so 24 hours after 02:00 is 01:00 local time the next day.
Then, if they want more
And since each run is computed from the previous one, the job stays an hour early until spring. plusDays(1) instead adds one calendar day on the local timeline and keeps the local time, so it gives 02:00 with the new offset. The real fix is to pick by intent.
If the requirement is the same wall-clock time every day, I use plusDays or a Period, or better, compute from the rule itself, today's date at 02:00 in the zone. If the requirement is elapsed time, like a token expiring after 24 hours, I use Duration on an Instant.
In practice I would rather use a scheduler, for example Spring's cron with a zone, which works in wall-clock time, but I would check and test how it treats the gap and overlap hours, because a job inside 01:00 to 03:00 can be skipped, shifted or run twice.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- The Java Language Specification, Java SE 21, Java SE 21 API documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "A job scheduled with plusHours(24) on a ZonedDateTime runs at 01:00 instead of 02:00...": https://scrivio-interview-library.netlify.app/java/date-and-time/752fdd0c65/