I have a 'Fri Jan 16 08:41:11 GMT 2015' datetime string in my database.
I would like to parse it as a mysql datetime format String.
I am trying the code below, but getting
java.text.ParseException: Unparseable date: "Fri Jan 16 08:41:11 GMT 2015".
Code is:
String date = null;
if(pos.get("utc") != null) {
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date parsed = sdf.parse("Fri Jan 16 08:41:11 GMT 2015");
date = sdf.format(parsed);
} catch (JSONException | ParseException e) {
e.printStackTrace();
}
}
Any suggestions would be appreciated.
DateFormatpattern. Does it match your date String?