Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
To write test I need to set
LocalDateTime
to
0000-00-00 00:00:00
.
When I try to set it using formatter:
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime.parse("0000-00-00 00:00:00", formatter)
it throws an exception:
java.time.format.DateTimeParseException: Text '0000-00-00 00:00:00' could not be parsed: Invalid value for YearOfEra (valid values 1 - 999999999/1000000000): 0
How can I do this?
There's no day 0 in any month. Days always starts in 1
There's no month 0 in any year. Months always starts in 1
There's no year 0 in the Gregorian calendar. That's the error you're getting (Invalid value for YearOfEra
). You should set a year greater than 0
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.