Question 191 of 509

Quick Answer

The answer is to replace SimpleDateFormat with DateTimeFormatter.ISO_INSTANT and use Instant.from(). This is correct because SimpleDateFormat is not thread-safe—its internal calendar state gets corrupted when reused across threads, causing DateTimeParseException or wrong values under load. DateTimeFormatter.ISO_INSTANT, by contrast, is immutable and thread-safe by design, so it handles concurrent parsing without synchronization overhead, preserving performance. On the Oracle Certified Professional Java SE 17 Developer 1Z0-829 exam, this question tests your understanding of thread-safe date-time parsing in the java.time package, a frequent trap where developers stick with legacy SimpleDateFormat out of habit. The key insight is that java.time formatters are inherently safe for multi-threaded reuse, while SimpleDateFormat requires external synchronization or a new instance per thread. Memory tip: “ISO Instant is instant-safe—no sync needed.”

1Z0-829 Practice Question: Handling Date, Time, Text, Numeric and Boolean Values

This 1Z0-829 practice question tests your understanding of handling date, time, text, numeric and boolean values. The scenario asks you to isolate a root cause — eliminate options that address a different problem before choosing. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

A financial application uses Java SE 17 with a custom date format. The requirement is to parse strings like "2023-12-31T23:59:59.999Z" into an Instant. The existing code uses SimpleDateFormat with pattern "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" and then calls parse(). It works fine in single-threaded testing, but in production under load, intermittent parsing failures occur with DateTimeParseException or wrong values. The application is multi-threaded and reuses the same formatter instance. Which single change should be made to fix the issue while maintaining performance?

Question 1hardmultiple choice
Read the full NAT/PAT explanation →

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Replace SimpleDateFormat with DateTimeFormatter.ISO_INSTANT and use Instant.from()

Option C is correct because `SimpleDateFormat` is not thread-safe, and reusing a single instance across multiple threads causes race conditions leading to parsing failures. Replacing it with `DateTimeFormatter.ISO_INSTANT` (which is immutable and thread-safe) and using `Instant.from()` directly parses the ISO 8601 string without any synchronization overhead, maintaining performance while fixing the concurrency bug.

Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Wrap the parse call in a synchronized block

    Why it's wrong here

    Thread-safe but causes contention, reducing performance.

  • Use a ThreadLocal<SimpleDateFormat> to give each thread its own instance

    Why it's wrong here

    Works but is more complex and less performant than using DateTimeFormatter.

  • Replace SimpleDateFormat with DateTimeFormatter.ISO_INSTANT and use Instant.from()

    Why this is correct

    Thread-safe and correct for ISO 8601.

    Related concept

    Read the scenario before looking for a memorised answer.

  • Create a new SimpleDateFormat instance for each parse call

    Why it's wrong here

    Avoids thread safety but creates many objects, hurting performance.

Common exam traps

Common exam trap: answer the scenario, not the keyword

The trap here is that candidates often choose `ThreadLocal<SimpleDateFormat>` (Option B) because it technically fixes the thread-safety issue, but they overlook that the modern `java.time` API is the recommended, simpler, and more performant solution for Java SE 17, and that the exam expects you to prefer the new API over patching the old one.

Detailed technical explanation

How to think about this question

`SimpleDateFormat` internally uses a `Calendar` object that is mutated during parsing, so concurrent calls corrupt the internal state. `DateTimeFormatter.ISO_INSTANT` is designed to be immutable and thread-safe, and it directly parses the standard ISO 8601 format (e.g., `2023-12-31T23:59:59.999Z`) without needing a custom pattern. Under the hood, `Instant.from()` delegates to `DateTimeFormatter.ISO_INSTANT.parse()` which handles the fractional seconds and 'Z' suffix correctly, avoiding the common pitfall of `SimpleDateFormat` misinterpreting 'Z' as a literal instead of a timezone designator.

KKey Concepts to Remember

  • Read the scenario before looking for a memorised answer.
  • Find the constraint that changes the correct option.
  • Eliminate answers that are true in general but not in this case.

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Real-world example

How this comes up in practice

A small business has 20 workstations on the 192.168.1.0/24 network and one public IP from its ISP. The router uses PAT (NAT overload) so all 20 devices share one public address using different source ports. NAT questions test whether you understand the four address terms and which direction each translation applies.

What to study next

Got this wrong? Here's your next step.

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Related practice questions

Related 1Z0-829 practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Practice this exam

Start a free 1Z0-829 practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this 1Z0-829 question test?

Handling Date, Time, Text, Numeric and Boolean Values — This question tests Handling Date, Time, Text, Numeric and Boolean Values — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: Replace SimpleDateFormat with DateTimeFormatter.ISO_INSTANT and use Instant.from() — Option C is correct because `SimpleDateFormat` is not thread-safe, and reusing a single instance across multiple threads causes race conditions leading to parsing failures. Replacing it with `DateTimeFormatter.ISO_INSTANT` (which is immutable and thread-safe) and using `Instant.from()` directly parses the ISO 8601 string without any synchronization overhead, maintaining performance while fixing the concurrency bug.

What should I do if I get this 1Z0-829 question wrong?

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

What is the key concept behind this question?

Read the scenario before looking for a memorised answer.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Keep practising

More 1Z0-829 practice questions

Last reviewed: Jun 11, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

This 1Z0-829 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-829 exam.