Reputation: 4328
I'm working on internationalizing my app, and I've been setting my device to different locales and testing out the TimePickerDialog
to make sure that it displays the time pickers in the correct format for that locale.
It displays the correct time pickers for U.S. (AM/PM) format.
For Germany, I expected it to display the time picker in 24-hour format, but instead it displays it in 12-hour format with vorm./nachm. options.
But the one I am really confused about is when I set my device locale to French, the time picker displays time in a 12-hour format with AM/PM, just like for the U.S. I would have also expected this to display the pickers in 24-hour format.
Is this the expected behavior for a TimePickerDialog
?
Upvotes: 3
Views: 1159
Reputation: 4328
Okay I just found the solution.
The final argument to the constructor for TimePickerDialog
lets you specify a boolean called is24HourView
.
So you can check this dynamically using:
TimePickerDialog tpd = new TimePickerDialog(
getActivity(),
this,
hour,
minute,
DateFormat.is24HourFormat(getActivity()));
Upvotes: 4