Scrivio Interview library
ConceptFoundations6 min read · updated 12 November 2026

Explain the difference between Instant, LocalDateTime, OffsetDateTime and ZonedDateTime. Which of them represents a single unambiguous moment?

Instant is a point on the UTC timeline, counted in seconds and nanoseconds from the epoch. LocalDateTime is only a calendar date and a clock time with no zone, so on its own it is not a moment. OffsetDateTime adds a fixed offset such as +02:00, and ZonedDateTime adds a region such as Europe/Paris with its rules; Instant, OffsetDateTime and ZonedDateTime all identify one unambiguous moment, but only ZonedDateTime knows about daylight saving changes.

Why this question is asked

These four types are where most Java time bugs start, because they all print something that looks like a date and time, and the compiler is happy with any of them. Interviewers ask this question to see whether we understand what each type means, not only what it prints, since the wrong choice usually shows up months later as a report that is an hour off or a job that runs twice. In this answer, we will build up from the simplest idea of a moment, look at each type with code, see which ones are unambiguous and why, and then compare how they behave across a daylight saving change.

1A Quick Recap: Moments Versus Wall-Clock Readings

There are two different things we can mean by a time. One is a moment: the instant a payment was made, the same for everyone on Earth. The other is a reading on a wall clock: '09:00 on 10 March', which happens at a different moment in London and in Tokyo. To turn a wall-clock reading into a moment, we need to know where the clock hangs.

Two more terms help. An offset is a fixed difference from UTC, such as +05:30 or -04:00. A time zone, written as an IANA region ID such as America/New_York, is a set of rules that says which offset applies on which date, including daylight saving time (DST), when clocks move forward in spring and back in autumn. New York uses -05:00 in winter and -04:00 in summer, so the zone is more than an offset.

2Instant: A Point on the Timeline

An Instant is simply a count of seconds and nanoseconds since the epoch, 1970-01-01T00:00:00Z. It has no calendar fields of its own and no zone. It prints in UTC, marked by the trailing Z, only because UTC is the neutral way to display it.

Java
Instant paid = Instant.parse("2025-03-10T08:00:00Z");
System.out.println(paid); // 2025-03-10T08:00:00Z
System.out.println(paid.getEpochSecond()); // 1741593600
System.out.println(paid.atZone(ZoneId.of("Asia/Tokyo"))); // 2025-03-10T17:00+09:00[Asia/Tokyo]
System.out.println(paid.atZone(ZoneId.of("America/New_York"))); // 2025-03-10T04:00-04:00[America/New_York]

Notice that the same Instant shows as 17:00 in Tokyo and 04:00 in New York. The moment did not change; only the wall clock we read it from did. That is why Instant is the right type for 'when did this happen': logs, events, created_at columns.

3LocalDateTime: A Date and Time With No Place

A LocalDateTime holds a year, month, day, hour, minute, second and nanosecond, and nothing else. It does not know whether it means Paris or Chicago, so it cannot be placed on the timeline until we supply a zone.

Java
LocalDateTime meeting = LocalDateTime.of(2025, 3, 10, 9, 0);
System.out.println(meeting); // 2025-03-10T09:00
System.out.println(meeting.atZone(ZoneId.of("Europe/Paris")).toInstant()); // 2025-03-10T08:00:00Z
System.out.println(meeting.atZone(ZoneId.of("America/Chicago")).toInstant()); // 2025-03-10T14:00:00Z
// meeting.toInstant() does not compile: there is no such method without an offset

The same LocalDateTime becomes two moments six hours apart, depending on the zone we attach. So a LocalDateTime is not a moment on its own. It is still useful, for example as the wall-clock part of a future appointment, but it must travel together with a zone.

4OffsetDateTime and ZonedDateTime: Adding the Missing Piece

OffsetDateTime is a LocalDateTime plus a fixed ZoneOffset. Because the offset is fixed, the moment is fully determined: 09:00+01:00 is exactly 08:00Z. ZonedDateTime is a LocalDateTime plus a ZoneId, a region with rules. It also stores the offset that those rules give for that date, so it too pins down exactly one moment.

Java
OffsetDateTime o = OffsetDateTime.of(2025, 3, 10, 9, 0, 0, 0, ZoneOffset.ofHours(1));
System.out.println(o); // 2025-03-10T09:00+01:00
System.out.println(o.toInstant()); // 2025-03-10T08:00:00Z
ZonedDateTime z = ZonedDateTime.of(2025, 3, 10, 9, 0, 0, 0, ZoneId.of("Europe/Paris"));
System.out.println(z); // 2025-03-10T09:00+01:00[Europe/Paris]
System.out.println(z.getOffset()); // +01:00, resolved from the zone's rules for this date
System.out.println(z.toInstant()); // 2025-03-10T08:00:00Z
The four types side by side
TypeWhat it holdsOne moment?Knows DST rules?
Instantseconds + nanos since 1970-01-01ZYesNo (no calendar at all)
LocalDateTimedate + time onlyNoNo
OffsetDateTimedate + time + fixed offsetYesNo
ZonedDateTimedate + time + ZoneId + resolved offsetYesYes

So the answer to the question is that Instant, OffsetDateTime and ZonedDateTime each represent a single unambiguous moment, and LocalDateTime does not. The difference between the last two is what they know about the future, which shows up when we do arithmetic.

5Where ZonedDateTime and OffsetDateTime Part Ways

In New York, clocks moved from -05:00 to -04:00 on 9 March 2025. Let us add one day to 09:00 on 8 March with each type.

Java
ZonedDateTime z = ZonedDateTime.of(2025, 3, 8, 9, 0, 0, 0, ZoneId.of("America/New_York"));
System.out.println(z.plusDays(1)); // 2025-03-09T09:00-04:00[America/New_York]
OffsetDateTime o = z.toOffsetDateTime();
System.out.println(o.plusDays(1)); // 2025-03-09T09:00-05:00

Both still say 09:00, but they are different moments. The ZonedDateTime consulted New York's rules and moved to the summer offset, so it is 09:00 on a New York wall clock. The OffsetDateTime kept -05:00, because it has no rules to consult, so its result is 10:00 on a New York wall clock. That is the practical meaning of 'ZonedDateTime handles DST arithmetic and OffsetDateTime does not'.

6Follow-up questions

When would you prefer OffsetDateTime over ZonedDateTime?

When we are recording or exchanging a moment rather than computing with local rules. An OffsetDateTime maps cleanly to ISO-8601 strings such as 2025-03-10T09:00+01:00 and to SQL timestamp with time zone, and it does not depend on the reader having the same zone rules as the writer. So it suits API payloads, database values and logs. We prefer ZonedDateTime when we need to do calendar arithmetic in a user's zone, like 'same time next week', or when we schedule future events where DST rules matter.

Is Instant always in UTC?

An Instant has no zone at all; it is a count from the epoch. It prints in UTC because that is a neutral format, but there is nothing to convert until we call atZone or atOffset.

Why can we not call toInstant() on a LocalDateTime?

Because the answer depends on a zone the object does not have. Java makes us say it, either with atZone(zone).toInstant() or toInstant(offset), so the choice is visible in the code rather than taken silently from the server's default zone.

7Conclusion

In this answer, we separated moments from wall-clock readings. Instant is a pure point on the timeline. LocalDateTime is a date and time with no place, so it is not a moment until we add a zone. OffsetDateTime adds a fixed offset and ZonedDateTime adds a region with rules plus the resolved offset, so both are unambiguous. We also saw the difference that matters most in practice: ZonedDateTime follows DST rules in arithmetic, while OffsetDateTime keeps its fixed offset.

What to say in the interviewAbout 70 seconds aloud

Open with

The key distinction is between a moment and a wall-clock reading. Instant is a moment: seconds and nanoseconds since the epoch, displayed in UTC, and it is unambiguous.

Then, if they want more

LocalDateTime is just a date and a time with no zone or offset, so it is not a moment by itself; the same LocalDateTime is a different instant in Paris and in Chicago. OffsetDateTime is a LocalDateTime plus a fixed offset like plus one hour, which fixes the moment exactly.

ZonedDateTime is a LocalDateTime plus a region ID such as Europe/Paris, and it also tracks the offset those rules give, so it is unambiguous too. So three of the four represent a single moment: Instant, OffsetDateTime and ZonedDateTime. The practical difference between the last two is arithmetic.

ZonedDateTime knows DST rules, so plusDays across a DST change keeps the local time and moves the offset. OffsetDateTime keeps its offset, so the result is an hour off in local terms. I use Instant for recording when something happened, OffsetDateTime for exchanging moments in APIs and databases, and ZonedDateTime when I calculate in a user's zone.

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.
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 "Explain the difference between Instant, LocalDateTime, OffsetDateTime and ZonedDateTime....": https://scrivio-interview-library.netlify.app/java/date-and-time/064a800812/