Android黄色警告汇总
1.
Warning:
// To get local formatting use getDateInstance(), getDateTimeInstance(), or
// getTimeInstance(), or use new SimpleDateFormat(String template, Locale
// locale) with for example Locale.US for ASCII dates.@SuppressLint("SimpleDateFormat")
String string = new SimpleDateFormat("EEEE yyyy-MM-dd",Locale.getDefault()).format(new Date());
Solution:
添加Locale.getDefault()
for example,like:
SimpleDateFormat newSimpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日HH时mm分",Locale.getDefault());
2.Warning:
Implicitly using the default locale is a common source of bugs: Use toUpperCase(Locale) instead
String string = new SimpleDateFormat("EEEE",Locale.getDefault()).format(new Date()).toUpperCase();
Solution:
由于大写一般只应用在英语国家,所以Locale指定为Locale.US
String string = new SimpleDateFormat("EEEE",Locale.getDefault()).format(new Date()).toUpperCase(Locale.US);
(有时警告提示仍在,需要clean下才会消除)
未完待续......
更多相关文章
- 解决Android(安卓)Studio报的警告:Resource IDs will be non-fina
- android 各种常用,不易记的dialog,等控件整理
- Android(安卓): Android(安卓)Studio 3.4更新至gradle 5.1.1的问
- Android添加圆角渐变色按钮
- Your anti-virus program might be impacting your build perfor
- 去掉 Android工程中让人很不爽的“黄色警告”
- Android最新获取oaid的方法及sdk
- Android英语单词记忆程序源码
- 去除警告 Android(安卓)NDK: WARNING: APP_PLATFORM Android-14