title: Format a datetime string to time only
body: <p>I'm retrieving a datetime from a SQLite DB which comes out in the format...</p>
  
  <pre><code>2011-01-24 02:45:00
  </code></pre>
  
  <p>In C# I can simply use <code>DateTime.Parse("2011-01-24 02:45:00").ToString("HH:mm")</code> in order to get the string <code>02:45</code></p>
  
  <p>Is their a way I can I do this in Android/Java? My code in my Android app looks like this...</p>
  
  <pre><code>// 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); // &lt;-- throws IllegalArgumentException
  </code></pre>
  
  <p><strong>EDIT:</strong> Thanks to both doc_180 and Konstantin Burov - the examples given have helped me sort out the problem. Part of the issue was that I was importing java.sql.Date instead of java.util.Date. I've changed things around and it's working perfectly for me now.</p>