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

ⅰ亾dé卋堺 提交于 2019-11-30 01:13:36

问题


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.


回答1:


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)



回答2:


This may help you....

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



来源:https://stackoverflow.com/questions/6649815/how-can-i-determine-whether-a-device-is-using-12-or-24-hour-time-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!