24

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.

Swati Garg
  • 901
  • 1
  • 10
  • 21
brig
  • 3,490
  • 12
  • 40
  • 60

2 Answers2

58

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)
MrJre
  • 7,022
  • 7
  • 53
  • 64
  • Thank U MrJre, This is what I am looking for. – brig Jul 12 '11 at 06:26
  • 3
    *Caution:* Using this can result in a null value being returned to your application. As specified in this answer http://stackoverflow.com/a/7922264/181211 , a better solution is `DateFormat.is24HourFormat()` . MrJre, I recommend updating your answer. – CrimsonX Aug 04 '14 at 19:07
  • This is what i was looking for. – andre719mv Oct 02 '16 at 20:59
9

This may help you....

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

efkan
  • 12,256
  • 6
  • 68
  • 101
Farhan
  • 3,152
  • 13
  • 45
  • 62