I have a response from an API for a date field.

```
"billCycleDate":"2022-07-15T00:00:00-05:00"

```

I'm trying to convert this to a "dd-MM-yyyy" date format. The easy way is to simply extract the date from the string and then convert into the format I want. But I wanted to know if there is a 'correct' way of doing this.

The following code is what I've been using:

```
inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss Z", Locale.ENGLISH);
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("dd-MM-yyy", Locale.ENGLISH);
LocalDate date = LocalDate.parse(localBill.getBillCycleDate(), inputFormatter);
formattedDate = outputFormatter.format(date);

```

I've tried different patterns ("yyyy-MM-dd'T'HH:mm:ss.SSSXXX", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", etc.) but none of them seem to work. It throws the following error:

```
java.time.format.DateTimeParseException: Text '2022-07-15T00:00:00-05:00' could not be parsed at index 19

```