gpt4 book ai didi

android - 调用需要 api 级别 24(当前最小值为 21)新的 android.icu.text.DecimalFormat

转载 作者:搜寻专家 更新时间:2023-11-01 08:28:09 25 4
gpt4 key购买 nike

抱歉,我是新手,如何在较旧的 API 中调用它或?获取此警告调用需要 api 级别 24(当前最小值为 21)新的 android.icu.text.DecimalFormat

public static String roundThousandsIntoK(Number number) {
char[] suffix = {' ', 'k', 'M', 'B', 'T', 'P', 'E'};
long numValue = number.longValue();
int value = (int) Math.floor(Math.log10(numValue));
int base = value / 3;
if (value >= 3 && base < suffix.length) {
return new DecimalFormat("#0.0").format(numValue / Math.pow(10, base * 3)) + suffix[base];
} else {
return new DecimalFormat("#,##0").format(numValue);
}
}

最佳答案

你应该使用java的十进制格式

java.text.DecimalFormat

更多请引用http://tutorials.jenkov.com/java-internationalization/decimalformat.html

关于android - 调用需要 api 级别 24(当前最小值为 21)新的 android.icu.text.DecimalFormat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42895100/

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