Exception Unable to obtain LocalDateTime from TemporalAccessor while parsing DateTime using LocalDateTime

Viewed 3377

Getting Exception while parsing the DateTime. Is something i am missing here

DateTimeFormatter formatter =  DateTimeFormatter.ofPattern("0DDDHHmmss");
DateTimeFormatter.ofPattern("0DDDHHmmss");
LocalDateTime date = LocalDateTime.parse("0365231109", formatter).withYear(2016);

Following is the exception i am getting

Exception in thread "main" java.time.format.DateTimeParseException: Text '0365231109' could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: {DayOfYear=365},ISO resolved to 23:11:09 of type java.time.format.Parsed
    at java.time.format.DateTimeFormatter.createError(DateTimeFormatter.java:1920)
    at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1855)
    at java.time.LocalDateTime.parse(LocalDateTime.java:492)
    at AutocomFDParser.main(AutocomFDParser.java:204)
Caused by: java.time.DateTimeException: Unable to obtain LocalDateTime from TemporalAccessor: {DayOfYear=365},ISO resolved to 23:11:09 of type java.time.format.Parsed
    at java.time.LocalDateTime.from(LocalDateTime.java:461)
    at java.time.format.Parsed.query(Parsed.java:226)
    at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851)
    ... 2 more
Caused by: java.time.DateTimeException: Unable to obtain LocalDate from TemporalAccessor: {DayOfYear=365},ISO resolved to 23:11:09 of type java.time.format.Parsed
    at java.time.LocalDate.from(LocalDate.java:368)
    at java.time.LocalDateTime.from(LocalDateTime.java:456)
2 Answers
Related