I'm trying to parse this date: Mon, 05 Jul 2021 23:19:58 IST
String date = "Mon, 05 Jul 2021 23:19:58 IST";
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.getDefault());
dateFormat.parse(date);
But I'm getting this error: java.text.ParseException: Unparseable date: "Mon, 05 Jul 2021 23:19:58 IST"
When I omit the lowercase z from the format, I don't get the exception, but the date isn't in the correct timezone. I've tried doing the following:
dateFormat.setTimeZone(TimeZone.getTimeZone("IST"));
But the date still shows in the future, which is incorrect. How can I correctly parse this date? Thank you.