Search code examples
androidtimepicker

How to get selected am_pm value from TimePicker in Android


I was using a Time picker from which user can set or change time and save to database. I was able to pick Hour(s) and Minutes(s) from Time Picker using,

TimePicker getTimepickerTime = (TimePicker) findViewById(R.id.timePicker1);
int Hour= getTimepickerTime.getCurrentHour();
int Minute=getTimepickerTime.getCurrentMinute();

but how to pick the am_pm value from Time Picker?

Please suggest me. I was stuck here.

Any Help will be Appreciated!!


Solution

  • If we trust this post timepickerdialog-and-am-or-pm you don't need to get am/pm value cause hour will be always in 24h format. Timepicker display ap/pm but return 24h format value.