QuestionQ193

Working with Selected Classes from the Java API

Given this code fragment:

Question Image

What is the outcome?

  • A May 04, 2014T00:00:00.000
  • B 2014-05-04T00:00: 00.000
  • C 5/4/14T00:00:00.000
  • D An exception is thrown at runtime.
Explanation

LocalDate contains only calendar-date fields, whereas DateTimeFormatter.ISO_DATE_TIME formats an ISO date-time and needs time fields. Formatting therefore fails with UnsupportedTemporalTypeException, which is a runtime exception.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!