title: How to change date and time format from"yyyy-MM-dd HH:mm:ss" to "h:mm a"?
body: <p>I am using below code to format data and time as time.But it does not work can anyone help me how to fix this problem.</p>
  
  <pre><code> try {
           String actualDate = m.getDate();//get date as"28-aug-2015 6:46:32 pm"
           Date Date= new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss").parse(actualDate);
           convertDate = new SimpleDateFormat("h:mm a").format(Date);//6:46 am  
      }
      catch (ParseException e) {
  
           e.printStackTrace();
      }
  </code></pre>
  
  <p>after converting the format i got my "convertDate" value as "6.46 am" but now time is "6:46 pm" how can i fix this problem.</p>