0

I am trying to parse a date time string to joda date time. But, getting malformed error.

Joda 2.10.1

DateTimeFormatter parser = DateTimeFormat.forPattern("EEE MMM dd HH:mm:ss zzz yyyy");
DateTime dateTime = parser.parseDateTime("Thu Mar 28 12:26:50 IST 2019");

Exception in thread "main" java.lang.IllegalArgumentException: Invalid format: "Thu Mar 28 12:26:50 IST 2019" is malformed at "IST 2019"

I am able to parse using java8 time API. But, my app is a legacy one and can't use this. Need help to fix this.

Manu
  • 269
  • 6
  • 18

1 Answers1

0

Did you check, that IST is a valid timezone? At least it is not listed here: List of time zone abbreviations

liecno
  • 924
  • 1
  • 8
  • 18
  • It is not. "Asia/Kolkata" is the closest actual TZ – James Gawron Feb 07 '20 at 19:17
  • @liecno I am getting the date string after parsing ISODate("2019-03-28T12:26:50.000Z"). As part of the string IST is coming. – Manu Feb 08 '20 at 08:35
  • It comes three times in that list, after IRST and before JST. – Ole V.V. Feb 08 '20 at 09:24
  • @Manu It sounds like you haven’t told us the whole story. A string is the result of formatting, not of parsing. If you can avoid getting a string after parsing, you can also avoid having to parse a second time. – Ole V.V. Feb 21 '20 at 16:04