I am currently using a TimePickerDialog to set the time and display it into a Edit Text .However, I am having problems with the formating.
I want to set the time in HH:MM format but it is set like H:mm format i want this 01:33 but my code giving me 1:33 output.
Here is the code :-
public void onTimeSet(TimePicker view, int hourOfDay, int minute){
String am_pm = "";
Calendar datetime1 = Calendar.getInstance();
datetime1.set(Calendar.HOUR_OF_DAY, hourOfDay);
datetime1.set(Calendar.MINUTE, minute);
if (datetime1.get(Calendar.AM_PM) == Calendar.AM)
am_pm = "AM";
else if (datetime1.get(Calendar.AM_PM) == Calendar.PM)
am_pm = "PM";
String strHrsToShow1 = (datetime1.get(Calendar.HOUR) == 00)?"12":datetime1.get(Calendar.HOUR)+"";
((EditText)getActivity().findViewById(R.id.End_time)).setText( strHrsToShow1+":"+datetime1.get(Calendar.MINUTE)+" "+am_pm);
}