I want to know the current device time format.
means 24 hour/ 12 hour format .
Plz let me know how can I determine that.
Are there any API there to determine this.
thanks.
9) Eighteen (18) Countries use the 12-hour clock: Australia, Bangladesh, Canada, Colombia, Egypt, El Salvador, Honduras, India, Ireland, Jordan, Malaysia, Mexico, New Zealand, Nicaragua, Pakistan, Philippines, Saudi Arabia and U.S. (although the military uses the 24-hour clock).
In the 24-hour clock format, each day runs from midnight to midnight and is divided into 24 hours. 24-Hour Time uses the numbers 00:00 (midnight) until 23:59 to tell the time. You don't need to use am / pm with a 24-Hour Clock, as afternoon is indicated by a number bigger than 12.
Now at the top of your phone or tablet, the time will now be displayed in 24-hour format or so-called military time. If you want to turn it off and go back to a 12-hour format you can. Just go back to Settings > System > Date & time and toggle off the “Use 24-hour format” button to the off position.
String value = android.provider.Settings.System.getString(context.getContentResolver(), android.provider.Settings.System.TIME_12_24);
Updated Answer, you should use this instead of the above, as above could give back a null value:
DateFormat.is24HourFormat(context)
This may help you....
The link of the answer source: https://developer.android.com/reference/android/text/format/DateFormat.html#is24HourFormat(android.content.Context)
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