Home > Back-end >  DateTime parsing exception in java
DateTime parsing exception in java

Time:12-16

I'm developing my mobile app with API. Binding datetime gives me error java.time.format.DateTimeParseException: Text '2022-12-16T00:00:00 03:00' could not be parsed, unparsed text found at index 19. Please help me format this weird date

fun formatDateOfReview(dateOfReview: String?): String? {
    val localDate = LocalDateTime.parse(dateOfReview)
    return localDate.format(DateTimeFormatter.ofPattern("dd.MM.yyyy"))
}

CodePudding user response:

2022-12-16T00:00:00 03:00

That is a combined date-time with a time zone in ISO 8601 format.

LocalDateTime.parse(dateOfReview)

LocalDateTime is "A date-time without a time-zone in the ISO-8601 calendar system" (emphasis added).

Please use OffsetDateTime instead.

  • Related