Reputation: 136
I got this error when I do this
LocalDate.parse(expirationDate,DateTimeFormatter.ofPattern("MM/yy");
java.time.format.DateTimeParseException: Text '09/14' could not be parsed at index 5
I have test with the builder but I don't know how to do it?
Someone had some clue ?
Thanks!
Upvotes: 1
Views: 1486
Reputation: 124215
LocalDate
needs to contain day. If you don't plan to provide it you can use YearMonth
instead.
YearMonth yearMonth = YearMonth.parse("09/14",DateTimeFormatter.ofPattern("MM/yy"));
You can later build LocalDate with some day value like
LocalDate firstDay = yearMonth.atDay(1);
Upvotes: 7