When I take datatime value from database then I get “java.text.ParseException: Unparseable date: 2008-06-29 20:45:00”
My code:
try {
Cursor cur = db.query("table", new String[] { "_id", "id_m", "date_time"}, "id_m=31", null, null, null, null);
startManagingCursor(cur);
cur.moveToFirst();
Date date = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS").parse(cur.getString(cur.getColumnIndex("date_time")));
long unixTimestamp = date.getTime() / 1000;
} catch (ParseException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
}
Can anybody explain me why?
The time in your database uses the 24-hour clock, but you have specified
hhfor your hours field which limits the value to 1 through 12. Your pattern should be