Format a datetime string to time only
I'm retrieving a datetime from a SQLite DB which comes out in the format... 2011-01-24 02:45:00 In C# I can simply use DateTime.Parse("2011-01-24 02:45:00").ToString("HH:mm") in order to get the string 02:45 Is their a way I can I do this in Android/Java? My code in my Android app looks like this... // dateStr below is logging as correctly being yyyy-MM-dd HH:mm:ss format String dateStr = cursor.getString(cursor.getColumnIndex("start_time")); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); String shortTimeStr = sdf.format(dateStr); // <-- throws IllegalArgumentException EDIT: Thanks to