Maybe it's little stupid question, but I lost some hours on it now and could be great if someone will find a time to share his experience.
I'm trying to parse the date from string: 2018-05-01 13:54:46 CEST
To parse this date I'm using following pattern: yyyy-MM-dd HH:mm:ss z
And code:
private fun dateFromStringUsingPattern(dateString : String, formatPattern : String) : Date? {
val simpleDateFormat = SimpleDateFormat(formatPattern, Locale.US)
try {
return simpleDateFormat.parse(dateString)
} catch (e : Exception) {
e.printStackTrace()
}
return null
}
But unfortunately I have exception java.text.ParseException: Unparseable date: "2018-05-01 13:54:46 CEST"
I also tested my pattern there http://www.sdfonlinetester.info/ and it seems to be ok.
What could be wrong?
Thanks