I have a String of date time information that I'm trying to convert into a LocalDate field. The String's contents are '2019-08-28 09:00:00'. I am trying to get a MM/dd/yyyy LocalDate value to load into a JavaFX DatePicker field.
I have tried
Date date = new SimpleDateFormat("MM/dd/yyyy").parse(stringDate);
and
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
LocalDate localDate = LocalDate.parse((CharSequence) date, formatter);
both of which have returned errors. The error returned from option #2 is as follows:
Caused by: java.time.format.DateTimeParseException: Text '2019-08-30 12:00:00' could not be parsed at index 2
at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1949)
at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851)
at java.time.LocalDate.parse(LocalDate.java:400)
at utils.DateTimeConverter.convertStringDateToLocalDate(DateTimeConverter.java:27)