title: Convert String to hh:mm format
body: <p>I am making an application in which i am geting a string in this format</p>
  
  <pre><code>2014-11-17 13:41:25
  </code></pre>
  
  <p>But what i want is only this</p>
  
  <pre><code>13:41
  </code></pre>
  
  <p>I tried doin this but i got forcse close</p>
  
  <pre><code>String test = new SimpleDateFormat("kk:mm").format(data.getStringExtra("TIME"));
  etStartTime.setText(test);
  </code></pre>
  
  <p><strong>LogCat :</strong></p>
  
  <pre><code>11-17 14:44:07.717: E/AndroidRuntime(14287): FATAL EXCEPTION: main
  11-17 14:44:07.717: E/AndroidRuntime(14287): java.lang.IllegalArgumentException: Bad class: class java.lang.String
  11-17 14:44:07.717: E/AndroidRuntime(14287):    at java.text.DateFormat.format(DateFormat.java:359)
  11-17 14:44:07.717: E/AndroidRuntime(14287):    at java.text.Format.format(Format.java:93)
  11-17 14:44:07.717: E/AndroidRuntime(14287):    at com.megasys.im3_new.workorder.TimeCard.onActivityResult(TimeCard.java:318)
  11-17 14:44:07.717: E/AndroidRuntime(14287):    at com.megasys.im3_new.workorder.TimeCard$TimePickerFragment.onTimeSet(TimeCard.java:383)
  11-17 14:44:07.717: E/AndroidRuntime(14287):    at android.app.TimePickerDialog.tryNotifyTimeSet(TimePickerDialog.java:130)
  11-17 14:44:07.717: E/AndroidRuntime(14287):    at android.app.TimePickerDialog.onClick(TimePickerDialog.java:115)
  11-17 14:44:07.717: E/AndroidRuntime(14287):    at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:169)
  11-17 14:44:07.717: E/AndroidRuntime(14287):    at android.os.Handler.dispatchMessage(Handler.java:107)
  11-17 14:44:07.717: E/AndroidRuntime(14287):    at android.os.Looper.loop(Looper.java:194)
  11-17 14:44:07.717: E/AndroidRuntime(14287):    at android.app.ActivityThread.main(ActivityThread.java:5370)
  11-17 14:44:07.717: E/AndroidRuntime(14287):    at java.lang.reflect.Method.invokeNative(Native Method)
  11-17 14:44:07.717: E/AndroidRuntime(14287):    at java.lang.reflect.Method.invoke(Method.java:525)
  11-17 14:44:07.717: E/AndroidRuntime(14287):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
  11-17 14:44:07.717: E/AndroidRuntime(14287):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
  11-17 14:44:07.717: E/AndroidRuntime(14287):    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>what i have done</p>
  
  <pre><code>try {
      String time = data.getStringExtra("TIME");
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      Date timeCompare;
      timeCompare = sdf.parse(time);
      Date currentTime = new Date();
      int comareResult = timeCompare.compareTo(currentTime);
  
      if (comareResult == -1) {
          // time = new SimpleDateFormat("HH:mm").format(time);
          Date testDate = null;
          SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-mm-dd HH:MM");
          try {
              testDate = sdf.parse(time);
          } catch(Exception ex) {
              ex.printStackTrace();
          }
  
          etStartTime.setText("" + testDate);
      }
  } catch(Exception ex) {
      ex.printStackTrace();
  }
  </code></pre>
  
  <p>This is what i had done ,but still am getting errors.</p>
  
  <p>The time i am getting from intent</p>
  
  <pre><code>public class TimePickerFragment extends DialogFragment implements TimePickerDialog.OnTimeSetListener {
      public int hour;
      public int min;
      public String time;
      Calendar c;
  
      @Override
      public Dialog onCreateDialog(Bundle savedInstanceState) {
          c = Calendar.getInstance();
  
          hour = c.get(Calendar.HOUR_OF_DAY);
          min = c.get(Calendar.MINUTE);
  
          // Create a new instance of DatePickerDialog and return it
          return new TimePickerDialog(getActivity(), this, hour, min, true);
      }
  
      @Override
      public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
  
          Calendar date = Calendar.getInstance();
          date.set(Calendar.HOUR_OF_DAY, hourOfDay);
          date.set(Calendar.MINUTE, minute);
          date.set(Calendar.AM_PM, date.get(Calendar.AM_PM));
          String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date.getTime());
  
          Intent intent = new Intent();
          intent.putExtra("TIME", time);
  
          getTargetFragment().onActivityResult(getTargetRequestCode(), 1, intent);
          getDialog().hide();
      }
  
      public String onTimeSelected() {
          return time;
      }
  
  }
  </code></pre>