有没有办法确定 Android 手机是否设置为 12 小时制或 24 小时制。我正在尝试实现以格式集显示时间。
boolean use24HourClock = ____________________
SimpleDateFormat timeFormat;
if (use24HourClock) {
timeFormat = new SimpleDateFormat("H:mm ", Locale.ENGLISH);
} else {
timeFormat = new SimpleDateFormat("h:mm a", Locale.ENGLISH);
}
I did not find a way to determine from the settings. Any suggestions?
最佳答案
您可以使用
DateFormat.is24HourFormat(context)
从android.text.format
判断是系统24小时还是12小时。
关于java - 确定用户是否在 Android 设备上将时钟设置为 24 小时格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59401570/