I'm trying to turn a String into LocalDate
using this code:
String end = sharedPref.getString("endDate", "Not available");
DateTimeFormatter formatter = new DateTimeFormatter("yyyy-MM-dd");
LocalDate endDate = LocalDate.parse(end, formatter);
But it shows the error mentioned in the title. How do I fix it? If there's a better way I'm open to suggestions
There are no constructor which took a format String, instead you have to call the static method ofPattern
like so :
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");