I am getting the time using a time picker and displaying the time in the text view using following code...
private TimePickerDialog.OnTimeSetListener mTimeSe
Calendar now = Calendar.getInstance();
if(now.get(Calendar.AM_PM) == Calendar.AM){
// AM
System.out.println(""+now.get(Calendar.HOUR)+":AM");
}else{
// PM
System.out.println(""+now.get(Calendar.HOUR)+":PM");
}
I have done like this to achieve it.
TimePickerDialog.OnTimeSetListener t = new TimePickerDialog.OnTimeSetListener() {
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
myCalendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
myCalendar.set(Calendar.MINUTE, minute);
update_From_Time();
}
};
DateFormat frmTime=DateFormat.getTimeInstance();
protected void update_From_Time() {
s = frmTime.format(myCalendar.getTime());
btnFromTime.setText(s);
}