I need to convert a Date object
(it shows this in debug mode---> "Mon Sep 23 00:00:00 EDT 2019") to another Date object
having "yyyy-MM-dd" format.
I tried the following code, but I get a runtime error saying:
java.time.format.DateTimeParseException: Text 'Mon Sep 23 00:00:00 EDT 2019' could not be parsed at index 0.
LocalDate localDate = LocalDate.parse(date.toString(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
Date result = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
Thanks for your help!.