I have a GMT String "Thr, 09 Jun 2022 19:20:00 GMT"
I want to convert this into Date.
Can anyone help how I convert this?
I tried every way but giving Unparseable date: "Thr, 09 Jun 2022 19:20:00 GMT"
Here is the code:
private fun getDate(time: String): Date? {
val pattern = "EEE, dd MMM yyyy HH:mm:ss Z"
val format = SimpleDateFormat(pattern)
var javaDate: Date? = null
try {
javaDate = format.parse(time)
} catch (e: ParseException) {
e.printStackTrace()
}
return javaDate
}
I referred to this question.
The site answer you're referring to just works.
You can run the example online over here
So it's likely that your input string doesn't match such pattern.
And indeed
Thris not valid. It should beThu. Here's the updated playground