Android 过时方法替换

最近公司代码质量检测,出来好多过时方法的使用,记录一下:

1.fromHtml

替换:

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
    content.setText(Html.fromHtml(html.replaceAll("span style", "font color").replaceAll("span", "font").replaceAll("color:", ""),Html.FROM_HTML_MODE_LEGACY));
} else {
    content.setText(Html.fromHtml(html.replaceAll("span style", "font color").replaceAll("span", "font").replaceAll("color:", "")));
}

2.new Date(.toLocaleString())

替换:

SimpleDateFormat sdf = (SimpleDateFormat) DateFormat.getDateTimeInstance();
sdf.format(new Date()
 

猜你喜欢

转载自blog.csdn.net/u010256329/article/details/100879322