Scrivio Interview library
LeadershipPrincipal7 min read · updated 12 November 2026

Time handling bugs keep causing incidents in your company: zone mix-ups, DST jobs and leap-day billing. What organisation-wide measures would you put in place, beyond telling teams to use java.time?

Telling teams to use java.time is not enough, because most time bugs come from choosing the wrong type, relying on a server's default zone, or never testing the awkward days. We fix that at the organisation level with a short written standard, a shared library and serialisation config, UTC servers with lint rules against zone-less now() calls, shared tests for DST and calendar edge cases, owned tzdata updates, and a review loop that keeps the standard current.

Why this question is asked

Time bugs are expensive in a quiet way. A billing job that runs twice in the autumn, an invoice that is a day late on 29 February, a report that shows orders in the future: each one looks like a one-off, and each team fixes its own copy. Interviewers ask this at a senior level because the real question is how we stop the same class of bug from recurring across fifty services, not how we fix one. In this answer, we will look at why the incidents keep coming, then at six measures that address their causes: a standard, a shared library, a UTC and lint policy, shared edge-case tests, tzdata ownership, and an incident review loop, and finally at how to roll them out without stalling teams.

1Why the Incidents Keep Coming Back

Most teams already use java.time. The trouble is that it offers several types that look alike: Instant, a point on the global timeline; LocalDateTime, a date and clock time with no zone; ZonedDateTime, a date and time in a region such as Europe/Paris with its daylight saving rules. The wrong one compiles fine and works on most days.

So the incidents share three root causes. The first is a wrong type choice, such as storing a LocalDateTime for an event that happened at one moment. The second is a hidden dependency on the default zone of whatever server the code runs on, through calls like LocalDate.now() with no argument. The third is that nobody tested the few days a year where the calendar is strange: the spring DST gap, the autumn overlap, month ends and 29 February. A library alone fixes none of these. Each measure below targets one of them.

2Measure 1: A Short Standard With Examples

We start with a one or two page standard that answers the question teams actually ask: which type do I use for this field? It should be short enough that people read it. The table below is the heart of it, and each row in the real document carries a code example.

The standard also names the forbidden patterns: java.util.Date and SimpleDateFormat in new code, zone abbreviations such as EST, and local date-times sent between systems without a zone. Notice that every rule is tied to an intent, not just a type name. Teams follow rules more willingly when they see the reason.

The core of the time standard
What the value meansType to useExample
When something happenedInstant (UTC)order placed, log event, token issued
A calendar date with no timeLocalDatebirthday, invoice date, billing anchor
A future local appointmentLocalDateTime + IANA ZoneId09:00 Monday in Europe/Paris
Elapsed time or a timeoutDuration from System.nanoTime()request took 230 ms
Calendar amountPeriodsubscription renews in 1 month
Each row in the real standard links to a code example and a test.

3Measure 2: A Shared Library and Serialisation Config

A standard on paper drifts unless the easy path follows it. So the platform team publishes a small shared library, often a Spring Boot starter, that every service pulls in. It configures Jackson to write instants as ISO-8601 strings in UTC instead of numbers, registers the same formats for Kafka and REST, sets Hibernate's time zone handling explicitly, and provides a Clock bean so code can ask for the current time in a testable way.

Java
@AutoConfiguration
public class TimeDefaultsAutoConfiguration {
@Bean @ConditionalOnMissingBean
Clock clock() { return Clock.systemUTC(); } // one source of "now" for the whole service
@Bean
Jackson2ObjectMapperBuilderCustomizer isoInstants() {
return b -> b.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
} // Instant -> "2025-03-09T07:30:00Z"
}

The reason this matters is consistency between services. When two teams serialise the same Instant differently, one as epoch milliseconds and one as a string with an offset, every consumer writes its own parsing code and some of it is wrong. With one library, the format is decided once. Jackson's configuration classes differ between Jackson 2 and Jackson 3 (used by Spring Boot 4), so check your version and keep that detail inside the library.

4Measure 3: UTC Servers and Lint Rules Against Hidden Zones

Next we remove the hidden dependency. All servers, containers and JVMs run in UTC, set explicitly with TZ=UTC or -Duser.timezone=UTC rather than inherited from a base image. But running in UTC only hides the bug; code that calls LocalDate.now() would still compute the wrong date for a customer in Tokyo. So the standard also says that domain code never relies on the default zone at all. It passes a Clock or an explicit ZoneId.

Lint rules make this enforceable. Error Prone has a check for java.time calls that silently use the default zone, and ArchUnit can fail the build when domain packages call now() without arguments. Notice that the rule is cheap to run on every build and catches the bug before review, which is far cheaper than catching it in an incident.

Java
@ArchTest
static final ArchRule noHiddenNow = noClasses()
.that().resideInAPackage("..domain..")
.should().callMethod(LocalDate.class, "now")
.orShould().callMethod(LocalDateTime.class, "now")
.orShould().callMethod(Instant.class, "now"); // build fails: "use the injected Clock"

5Measure 4: Shared Tests for the Awkward Days

Most of our incidents happened on a small set of dates. We collect them in shared test tooling so every team can run them with one line: the spring gap (2025-03-09 at 02:30 does not exist in America/New_York), the autumn overlap (2025-11-02 at 01:30 happens twice), the 31st of a month followed by a shorter month, 29 February, and the last day of the year when week-based years differ from calendar years.

A parameterised fixture with a fixed Clock lets a billing team write one test and run it against every awkward date. We centralise this because knowing which dates are dangerous is exactly what individual teams lack.

6Measure 5: Owning tzdata Updates

Java does not read the operating system's time zone rules. Each JDK carries its own copy of the IANA time zone database (tzdata), and governments change their rules several times a year, sometimes with only weeks of notice. If nobody owns updates, a service on an old JDK will show the wrong local time for a whole country after a change.

So we make tzdata part of JDK patching: a named platform team tracks IANA releases, rolls the JDK patch or the vendor's updater tool into the base images, and updates databases and operating systems at the same time.

7Measure 6: Learning From Every Incident

Finally, we close the loop. Every incident tagged as time-related gets a short review that asks one extra question: was this covered by the standard, the library, the lint rules or the shared tests? If not, we add it.

We roll this out gradually: standard and library first, lint rules as warnings and then as errors for new code, and the services that bill or schedule fixed first. The count of time-related incidents per quarter tells us whether it works.

Step throughHow a time incident feeds the standard
  1. Time-related incidentfor example a DST job ran twice
  2. Short review: root causewrong type, hidden zone, untested day or stale tzdata
  3. Covered by standard and tooling?
    YesFind why the rule was not appliedNoAdd a rule, lint check or shared test
  4. Publish library and docs updateteams get it with the next dependency bump
  5. Track incidents per quarterthe number should fall

5 steps in order. Play them, or step through them one at a time.

8Follow-up questions

How do you get teams to adopt the shared library rather than ignore it?

We make it the easiest path. It ships inside the standard service template, so new services get it for free, and it removes code teams would otherwise write themselves. For existing services, we offer a migration guide and pair with the first few teams. Lint rules that start as warnings and become errors for new code provide the push, and the platform team owns fixes in the library so teams are not stuck waiting.

Why not just make every server UTC and stop there?

Because UTC servers only remove variation between servers; they do not make the code correct. A service running in UTC that calls LocalDate.now() computes today's date for Greenwich, which is the wrong billing date for a customer in Sydney for ten hours of every day. The code still has to say which zone it means, explicitly, for anything that depends on a user's local calendar.

9Conclusion

In this answer, we saw that time incidents keep recurring because of three root causes: the wrong type for the job, a hidden reliance on the default zone, and untested calendar edge cases, plus stale tzdata. We addressed each with an organisation-wide measure: a short standard with examples, a shared library and serialisation config, UTC servers backed by lint rules, shared edge-case tests, a named owner for tzdata updates, and incident reviews that keep the standard current. Rolled out gradually and measured, these turn one team's lesson into everyone's default.

What to say in the interviewAbout 90 seconds aloud

Open with

I would treat this as a systems problem, because the incidents come from a few repeating causes: teams pick the wrong type, code depends on the server's default zone, and nobody tests DST days, month ends or leap days.

Then, if they want more

First I would publish a short standard that maps intent to type, for example Instant for when something happened, LocalDate for calendar dates, and local time plus an IANA zone for future appointments, each with an example.

Second, a shared library or Spring Boot starter that configures serialisation, so instants travel as ISO-8601 UTC strings everywhere, and provides a Clock bean. Third, every server runs in UTC, but domain code may not rely on that: lint rules with Error Prone or ArchUnit block now() calls without a clock or zone.

Fourth, shared test fixtures for the DST gap and overlap, the 31st, February 29th and year end, so teams test the dangerous dates with one line. Fifth, a named platform team owns tzdata updates as part of JDK patching, including base images and databases.

And finally, each time-related incident gets reviewed against the standard, and we add a rule or test when something was not covered. I would roll it out gradually, starting with billing and scheduling services, and measure time-related incidents per quarter.

About this answer

Last updated
12 November 2026
Versions it names
Spring Boot 4
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.
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 "Time handling bugs keep causing incidents in your company: zone mix-ups, DST jobs and...": https://scrivio-interview-library.netlify.app/java/date-and-time/575204d9c4/