I have a time picker dialog in my app. This works just fine, but I'd like to switch between the 12-hour and 24-hour picker dialogs based on the current locale. How do I find out which clock is used?
The dialog itself is launched like this:
boolean use24HourClock = true; // This i'd like to get from the locale
new TimePickerDialog(this, new TimePickerDialog.OnTimeSetListener()
{
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute)
{
}
}, 12, 00, use24HourClock).show();
Try this
boolean use24HourClock = DateFormat.is24HourFormat(getApplicationContext());
Returns true if user preference is set to 24-hour format.
See more about DateFormat here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With