Java ZonedDateTime DST Offset Transition Logic

Answer Correct answer: C — The output is true followed by false, reflecting the offset change from -05:00 to -06:00 while the local time structure behaves unexpectedly.

Daylight Saving Time (DST) is the practice of advancing clocks at the start of spring by one hour and adjusting them backward by one hour in autumn. Considering that in 2021, DST in Chicago (Illinois) ended on November 7th at 2 AM, and given the fragment: What is the output? - image

  1. true
  2. false
  3. true Correct Answer
  4. false

Community Votes

C
100%

100% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.

Community Insight

The exam tests understanding of how Java handles ambiguous times during DST transitions, specifically that plusHours(1) on 1:30 AM moves the clock back to 1:30 AM with a shifted offset.

This question tests the behavior of Java's ZonedDateTime when crossing a Daylight Saving Time transition boundary. It establishes that adding one hour to 1:30 AM during the fall-back transition results in a time with a different UTC offset.

Many candidates assume the time simply becomes 2:30 AM or remains at 1:30 AM without realizing the offset changes from -05:00 (CDT) to -06:00 (CST), leading to confusion about equality checks.

Community Discussion (7 comments)

ASPushkin 👍 1 Selected: C
The current date is November 7th time is 1:30 am November 7th 2am is a DST winter time ZonedDateTime zdt = ZonedDateTime.of( LocalDate.of(2021, 11, 7), LocalTime.of(1, 30), zoneId ); ZonedDateTime anHourLater = zdt.plusHours(1); means transition to DST winter zone and setting clocks back to one hour
Uteman 👍 1
C is the correct answer
xplorerpj 👍 1
C is the correct answer //zdt : 2021-11-07T01:30-05:00[America/Chicago] //anHourLater : 2021-11-07T01:30-06:00[America/Chicago] //zdt.Offset : -05:00 //anHourLater.Offset: -06:00
minhdev 👍 1
C is correct answer
james2033 👍 2 Selected: C
package q03; import java.time.LocalDate; import java.time.LocalTime; import java.time.ZoneId; import java.time.ZonedDateTime; public class Q03 { public static void main(String[] args) { ZoneId zoneId = ZoneId.of("America/Chicago"); ZonedDateTime zdt = ZonedDateTime.of( LocalDate.of(2021, 11, 7), LocalTime.of(1, 30), zoneId ); ZonedDateTime anHourLater = zdt.plusHours(1); System.out.println(zdt.getHour() == anHourLater.getHour()); System.out.print(zdt.getOffset().equals(anHourLater.getOffset())); } } // Result: // true // false
Samps 👍 1 Selected: C
C. true, false
gavishnu 👍 2
true, false

Comments & Corrections

No comments yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Submitted for moderation before publishing. Keep it helpful and respectful.

Expert Analysis

Why the Answer Is Correct

The code creates a ZonedDateTime for November 7, 2021, at 1:30 AM in Chicago. This is during the 'fall back' period where clocks turn back from 2 AM to 1 AM. The time 1:30 AM occurs twice: once in CDT (-05:00) and once in CST (-06:00). When plusHours(1) is called, Java advances the instant by one hour. Since it was already 1:30 AM, advancing one hour lands it at 1:30 AM again, but now in the standard time zone (CST). Therefore, the first output (checking if the hour changed or similar logic implied by option C being true) reflects the specific state before/after. Based on the community consensus and typical exam patterns for this snippet, the first boolean check usually verifies if the offset changed or if the local time representation matches expectations. Option C states 'true' then 'false'. Let's look at the comments. Comment 3 shows zdt is -05:00 and anHourLater is -06:00. If the code checks zdt.getOffset.equals(anHourLater.getOffset), it would be false. If it checks something else, we need the image. However, assuming the standard question format for this specific known issue: The first print is likely checking if the offset is different or if the time is valid. Wait, looking at option C: 'true' and 'false'. Comment 4 says 'true, false'. This implies two println statements. Without the image, we rely on the strong consensus for C. The key insight is the offset change.

Why the Other Options Are Wrong

Options A, B, and D do not match the observed behavior of the offset shifting from -05:00 to -06:00 while the local clock time might appear identical or shift depending on the specific comparison. The vote distribution heavily favors C, indicating it aligns with the actual execution result of the hidden code snippet.

Community Comment Notes

Users like james2033 and ASPushkin confirm that the transition involves setting clocks back. xplorerpj explicitly notes the offsets: -05:00 becoming -06:00. Gavishnu and others corroborate the answer as 'true, false', supporting option C.

Exam Strategy

Always visualize the DST transition map. For fall-back, remember that 1:00 AM to 1:59 AM happens twice. Adding an hour to the first occurrence jumps you to the second occurrence's start or continues the timeline, changing the offset.

Frequently Asked Questions

Why does the offset change when adding an hour?

Because the transition back to standard time means the same local hour exists in two different UTC offsets. Advancing the instant moves you to the later occurrence.

How does Java handle ambiguous times in ZonedDateTime?

It uses the Smarter Algorithm by default, preferring the earlier offset for ambiguous times unless specified otherwise, affecting how arithmetic operations resolve.

More 1Z0-829 FAQ →

Related Analysis

← Back to 1Z0-829 Study Guide