How can I improve the following code that I will share so that when I click on a button I will load the DatePickerDialog in 24 hours format if or yes, since at the moment it loads me in the format that the user has configured in his system, either 12 hours or 24 hours.
Here I share the code
public void obtenerHora(){
final Calendar c = Calendar.getInstance();
final int hour = c.get(Calendar.HOUR_OF_DAY);
final int minute = c.get(Calendar.MINUTE);
final int am_pm = c.get(Calendar.AM_PM);
TimePickerDialog recogerHora = new TimePickerDialog(getContext(), new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
//mEtHora: es un edit text que almacenara la hora seleccionada por el usuario
mEtHora.setText(hourOfDay + ":" + minute);
}
}, hour, minute, false);
recogerHora.show();
}
In some help I have seen that they use setIs24HourView (true) , but as long as it is a TimePicker embedded in the layout.