I try to parse this date "Wed Jul 12 2023 23:58:20 GMT+0000 (Coordinated Universal Time)" using this code
val sdf = SimpleDateFormat("EEE MMM dd yyyy HH:mm:ss ", Locale.getDefault())
val time = try {
val mDate = sdf.parse(input)
mDate!!.time
} catch (e: ParseException) {
-1
}
But I get this error
Unparseable date: "Wed Jul 12 2023 23:58:20 GMT+0000 (Coordinated Universal Time)"
This only happens if the localization changed. on my case the function works fine in English but when the app turns to Arabic here I faced the issue ,
I Changed Locale.getDefault() to Locale.ENGLISH and the problem solved