0

how can I format such a date:
2023-01-04T17:19:08+0100 in a string to a date in LocalDateTime using DateTimeFormatter or another tool ? It tries this way and throws a DateTimeParseException :

   private LocalDateTime parseLocalDateTime(String dateTime){

        final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:SS");
        return LocalDateTime.parse(dateTime, formatter);
    }
pawello12
  • 17
  • 5
  • Try `"yyyy-MM-dd'T'HH:mm:ssZ"` -- `SS` is milliseconds, not seconds, and you need to match the literal `T` and the offset. – tgdavies Jan 05 '23 at 13:03

0 Answers0