7

I'm receiving the date in the below format:

"Deadline": "2019-07-05T16:30:00"

And I'm trying to parse it using below formatter:

private val formatter: DateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH)

But I'm getting the following exception:

org.threeten.bp.format.DateTimeParseException: Text '2019-05-21T12:30:00' could not be parsed at index 19

Note: i'm using ThreeTenABP library

Davis Broda
  • 4,102
  • 5
  • 23
  • 37
Aditya Tyagi
  • 431
  • 3
  • 8
  • 1
    Looks like a bug in the library. – Henry Aug 09 '19 at 10:44
  • 1
    it is working for with java date time – Ryuzaki L Aug 09 '19 at 10:45
  • 1
    Weird. Index 19 is the end of the string. Could there be some non-printing character at the end of your format pattern string? BTW you don’t need to declare your own formatter for this string. Just use the built-in `DateTimeFormatter.ISO_LOCAL_DATE_TIME`. – Ole V.V. Aug 09 '19 at 11:02
  • 1
    @OleV.V. I've checked it.There isn't any character at the end of my format pattern string. – Aditya Tyagi Aug 09 '19 at 11:06
  • I cannot reproduce. Using jdk1.7.0_67, threetenbp-1.3.6 and your formatter I tried `LocalDateTime.parse("2019-05-21T12:30:00", formatter)`. It gave the expected result and no exception. Could you [create a Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example), please? – Ole V.V. Aug 09 '19 at 11:08
  • @OleV.V. The issue was from backend part the time format wasn't same but now it's fixed. Thanks for your time. – Aditya Tyagi Aug 13 '19 at 05:23

0 Answers0