Exception in thread "main" java.time.temporal.UnsupportedTemporalTypeException: Unsupported field: HourOfDay
at java.base/java.time.LocalDate.get0(LocalDate.java:709)
at java.base/java.time.LocalDate.getLong(LocalDate.java:688)
at java.base/java.time.format.DateTimePrintContext.getValue(DateTimePrintContext.java:308)
at java.base/java.time.format.DateTimeFormatterBuilder$NumberPrinterParser.format(DateTimeFormatterBuilder.java:2763)
at java.base/java.time.format.DateTimeFormatterBuilder$CompositePrinterParser.format(DateTimeFormatterBuilder.java:2402)
at java.base/java.time.format.DateTimeFormatterBuilder$CompositePrinterParser.format(DateTimeFormatterBuilder.java:2402)
at java.base/java.time.format.DateTimeFormatterBuilder$CompositePrinterParser.format(DateTimeFormatterBuilder.java:2402)
at java.base/java.time.format.DateTimeFormatter.formatTo(DateTimeFormatter.java:1849)
at java.base/java.time.format.DateTimeFormatter.format(DateTimeFormatter.java:1823)
at java.base/java.time.LocalDate.format(LocalDate.java:1813)
The Problem
LocalDate.parse("2014-05-04") correctly parses the string into a LocalDate object representing May 4, 2014.
However, when you try to format this LocalDate with DateTimeFormatter.ISO_DATE_TIME, it throws an error because ISO_DATE_TIME expects both date and time components, but LocalDate only contains date information.
Correct Answer is (d)
Exception is thrown as datetime formatter requires both date and time and only date is being provided here.
It will work fine if below is the input
String date = LocalDate.parse("2014-05-04").format(DateTimeFormatter.ISO_DATE);
This section is not available anymore. Please use the main Exam Page.1z0-808 Exam Questions
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
letmein2
Highly Voted 6 years, 3 months agoGyzmou
5 years agoMadan8899
Most Recent 1 month agoPoornima_D
5 months agoKarreRavi
5 months, 1 week agovic88
10 months, 4 weeks agoElanche
11 months, 3 weeks agonuray
1 year, 6 months agoDibya17
1 year, 7 months agofvelazqueznava
1 year, 10 months agogg7495
1 year, 11 months agoOndo
1 year, 11 months agoSezam
1 year, 12 months agodsms
2 years agosina_
2 years agoThando_4
2 years, 1 month agoNabilBenAsker
2 years, 1 month agofelipegomeztreufo
2 years, 2 months ago