title: showing current time in TimePicker in android
body: <p>i use this code to show current time in TimePicker, but i don't know really,why it doesn't show correctly!? for example now time (system time) is 2:56 PM, but it shows 2:56 AM!. how can i solve it? thanks.</p>
  
  <pre><code> private long timer1 = 0; 
   ...
  
  switch (view.getId()) {
          case R.id.add1: {
              if (timer1 == 0) {
                  timer1 = getCurrentTime();
              }
              Calendar calendar = Calendar.getInstance();
              calendar.setTimeInMillis(timer1);
  
              TimePicker timePicker = (TimePicker) findViewById(R.id.tp_1);
              timePicker.setCurrentHour(calendar.get(Calendar.HOUR));
              timePicker.setCurrentMinute(calendar.get(Calendar.MINUTE));
  
  
  
              break;
           . ..              
          }
  
  private long getCurrentTime() {
      Calendar calendar = GregorianCalendar.getInstance();
      return calendar.getTimeInMillis();
  }
  </code></pre>
  
  <p>and also i have the same problem when i want to convert this time into String form with this method below:</p>
  
  <pre><code>private String convertTimeToString(long time) {
      Calendar calendar = Calendar.getInstance();
      calendar.setTimeInMillis(time);
  
      int hour = calendar.get(Calendar.HOUR_OF_DAY);
      //int hour = get;
      int minute = calendar.get(Calendar.MINUTE);
  
      String timeSet;
      if (hour &gt; 12) {
          hour -= 12;
          timeSet = "PM";
      } else if (hour == 0) {
          hour += 12;
          timeSet = "AM";
      } else if (hour == 12) {
          timeSet = "PM";
      } else {
          timeSet = "AM";
      }
  
      String minutes;
      if (minute &lt; 10) {
          minutes = "0" + minute;
      } else {
          minutes = String.valueOf(minute);
      }
      // Append in a StringBuilder
      return String.format("%s:%s %s", hour, minutes, timeSet);
  
  }
  </code></pre>
  
  <p>please help me!</p>