nerdexam
Oracle

1Z0-808 · Question #38

public static void main(String[] args) { String date = "2014-05-04"; .parse("2014-05-04T00:00:00.000"); .format(DateTimeFormatter.ISO_DATE_TIME); System.out.println(date); } What is the result?

The correct answer is D. An exception is thrown at runtime. An exception java.time.temporal.UnsupportedTemporalTypeException is thrown at runtime. We should use class LocalDateTime with ISO_DATE_TIME format or use the format ISO_DATE to avoid the exception. See ISO_DATE_TIME at…

Localization

Question

public static void main(String[] args) { String date = "2014-05-04"; .parse("2014-05-04T00:00:00.000"); .format(DateTimeFormatter.ISO_DATE_TIME); System.out.println(date); } What is the result?

Options

  • AMay 04, 2014T00:00:00.000
  • B2014-05-04T00:00:00.000
  • C5/4/14T00:00:00.000
  • DAn exception is thrown at runtime.

How the community answered

(34 responses)
  • A
    3% (1)
  • B
    3% (1)
  • C
    9% (3)
  • D
    85% (29)

Explanation

An exception java.time.temporal.UnsupportedTemporalTypeException is thrown at runtime. We should use class LocalDateTime with ISO_DATE_TIME format or use the format ISO_DATE to avoid the exception. See ISO_DATE_TIME at https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html See examples at https://gist.github.com/mscharhag/9195718

Topics

#DateTimeFormatter#date parsing#LocalDateTime#Java date API

Community Discussion

No community discussion yet for this question.

Full 1Z0-808 Practice