gpt4 book ai didi

java - 确定用户是否在 Android 设备上将时钟设置为 24 小时格式

转载 作者:行者123 更新时间:2023-12-02 01:11:03 25 4
gpt4 key购买 nike

有没有办法确定 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com