title: How to compare two times with AM OR PM formate in android
body: <p>I want to compare two times like 12AM and 1AM. I have made following function to do this </p>
  
  <pre><code>public int timeValidation(){
      String stTime=btn_srt_time.getText().toString();
      String endtime=btn_end_time.getText().toString();
  
      SimpleDateFormat simpleDateFormat = new SimpleDateFormat("kk:mm");
  
       Date date1;
       Date date2;
      try {
  
          date1 = simpleDateFormat.parse(stTime);         
          System.out.println("================== date1=================="+date1);
  
          date2 = simpleDateFormat.parse(endtime);
          System.out.println("===========&gt; date 2 ==============&gt;"+date2);            
  
          return date1.compareTo(date2);
      } catch (ParseException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  
      return 0;
  
   }
  </code></pre>
  
  <p>It gives me right answer when comparison is between 12:00AM and 12:45AM.
  But when I am comparing 12:00AM and 1:00AM it says 1:00AM is before 12:00AM
  pls help...</p>