gpt4 book ai didi

android - 关于android日期格式的问题

转载 作者:行者123 更新时间:2023-11-29 22:24:16 25 4
gpt4 key购买 nike

android的源码有两个,但是没看懂是什么意思。并且手机无法更改日期格式,日期格式始终为 wday_month_day_no_year

mTimeFormat = DateFormat.getTimeFormat(getContext());
mDateFormatString = getContext().getString(R.string.full_wday_month_day_no_year);
refreshTimeAndDateDisplay();
updateStatusLines();



public void onTimeChanged() {
refreshTimeAndDateDisplay();
}

private void refreshTimeAndDateDisplay() {
mDate.setText(DateFormat.format(mDateFormatString, new Date()));
}

mDateFormatString = getContext().getString(R.string.full_wday_month_day_no_year); 是什么意思?

好吧,我更改了日期格式,但是在锁屏中,它没有按照我设置的日期格式显示日期。所以我不知道它有什么问题。在 lockSreen 中,它总是按“full_wday_month_day_no_year”显示日期格式。

请帮我解决这个问题。

最佳答案

format() 方法将字符串作为第一个参数。在这种特殊情况下,字符串在资源中定义,特别是在位于 res/values/strings.xml 的文件中,如

<string name="full_wday_month_day_no_year">E M d</string>

或类似的

日期格式引用:http://developer.android.com/reference/android/text/format/DateFormat.html

对于字符串资源:http://developer.android.com/guide/topics/resources/string-resource.html

关于android - 关于android日期格式的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6380720/

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