Select Date AM - PM Timepicker Android

Asked

Viewed 168 times

0

I have a Timepickerdialog configured in my project and is working properly.

When choosing the time I have the following option - PM or AM.

inserir a descrição da imagem aqui

Code:

private void timePicker(){
        // Get Current Time
        final Calendar c = Calendar.getInstance();
        mHour = c.get(Calendar.HOUR_OF_DAY);
        mMinute = c.get(Calendar.MINUTE);

        // Launch Time Picker Dialog
        TimePickerDialog timePickerDialog = new TimePickerDialog(this,
                new TimePickerDialog.OnTimeSetListener() {

                    @Override
                    public void onTimeSet(TimePicker view, int hourOfDay, int minute) {

                        mHour = hourOfDay;
                        mMinute = minute;

                        mHoraString = (hourOfDay + ":" + minute).toString();
                        mHora.setText(hourOfDay + ":" + minute);

                        /*milisegundos*/
                        long horaMil = TimeUnit.HOURS.toMillis(hourOfDay);
                        long minMil = TimeUnit.MINUTES.toMillis(minute);

                        long soma_mils = horaMil + minMil;

                        mHoraMilisegundos = Long.toString(soma_mils);
                    }
                }, mHour, mMinute, false);
        timePickerDialog.show();
    }

Works just right.

Would it have some simpler way or how is usually used this feature, to SIMPLIFY OR MAKE MORE EXPLICIT if the user wants to choose a time before Noon or After?

  • Is it mandatory to display am/pm? You cannot display the clock in 24h format?

  • Currently I show also in 24horas format. The question is whether it would have any more user-friendly form. @Leonardolima1

  • Currently I show also in 24horas format. The question is whether it would have any more user-friendly form. @Leonardolima1

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.