Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I determine whether a device is using 12 or 24-hour time format?

Tags:

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.

like image 949
brig Avatar asked Jul 11 '11 12:07

brig


People also ask

Who uses 12 hour format?

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).

How do I know my 24-hour format?

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.

What is 24-hour format in Android?

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.


2 Answers

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) 
like image 156
MrJre Avatar answered Sep 21 '22 09:09

MrJre


This may help you....

The link of the answer source: https://developer.android.com/reference/android/text/format/DateFormat.html#is24HourFormat(android.content.Context)

like image 33
Farhan Avatar answered Sep 20 '22 09:09

Farhan