I want to set an alarm based on a user's selection in TimePicker. TimePicker is set to AM/PM mode. In order to know if a user wants his alarm to set to 10 AM or 10 PM, how should I get the AM/PM value?
The listener TimePickerDialog.OnTimeSetListener
passes only hours and minutes.
Above answers are right i found simplest way to find AM PM.
TimePickerDialog.OnTimeSetListener onStartTimeListener = new OnTimeSetListener() {
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
String AM_PM ;
if(hourOfDay < 12) {
AM_PM = "AM";
} else {
AM_PM = "PM";
}
mStartTime.setText(hourOfDay + " : " + minute + " " + AM_PM );
}
};