title: Time format change according to time settings of phone
body: <p>I am having a string that returns both date and time from database as <code>2012-11-09 13:20:17</code>. Now I need to take the time from the database string and show the time like <code>13:20:17 pm</code> if the phone time settings is <code>24 hour</code> and if the phone time settings is <code>12 hour</code> I should show it as <code>01:20:17 pm</code>. The time format can be obtained by this line of code which shows whether its 24hr or 12hr </p>
  
  <pre><code>String timefrmt = Settings.System.getString(context.getContentResolver(),Settings.System.TIME_12_24);
  SimpleDateFormat timesettingsFormat=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
  date="2012-11-09 13:20:17";
  Date myDate=null;
  try {
       myDate=timesettingsFormat.parse(date);
  } catch (ParseException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
  } 
  if(timefrmt==null){
       timefrmt="hh:mm aa";
  }
  SimpleDateFormat timeFormat=new SimpleDateFormat(timefrmt);
  String time=timeFormat.format(myDate);
  </code></pre>
  
  <p>The sample code which I have tried is above but its crashing. Can anyone help me find a way for this.
  Thanks a lot</p>