views:

216

answers:

1

I have a TimePickerDialog with is24Hour set to false since I want to present the end-user with the more familiar 12 hour format. When the hour, minute and AM PM indicator are set and the time is returned how can I identify whether the end-user has selected AM or PM?

This is what I have for the listener:

private TimePickerDialog.OnTimeSetListener mTimeSetListener =
  new TimePickerDialog.OnTimeSetListener() {

@Override
public void onTimeSet(TimePicker view, int hourOfDay, 
  int minute) {
 mHour = hourOfDay;
 mMinute = minute;
// mIsAM = WHERE CAN I GET THIS VALUE
}

};

+1  A: 

The hourOfDay will always be 24-hour. If you opened the dialog with is24HourView set to false, the user will not have to deal with 24-hour formatted times, but Android will convert that to a 24-hour time when it calls onTimeSet().

CommonsWare
Great thanks for the quick response. I didn't get that from the documentation.
Yeah, well, it's not really in the documentation... :-)
CommonsWare