1.1万、9999.9万、1.1亿、999亿+
* 播放量的数字显示规则
1-9999,按照实际数字显示
10000-9999999,按照1万、1.1万、9999.9万
100000000-99900000000,按照1亿、1.1亿、999亿
>99900000000,统一显示为999亿+
所有数字显示均保留到小数点后一位即可
“`java
/**
* 视频观看次数、评论数
*
* @paramtimes
* @return
*/
public static String watchNum(String times) {
String timeStr= “”;
long count= 0;
try {
count= Long.parseLong(times);
} catch (NumberFormatException e) {
return timeStr;
}
if (count== 0) {
return timeStr;
} else if (count< 10000) {
return times;
} else if (count< 999 * 100000) {
long start= count/ 10000;
long end= count% 10000 / 1000;
if (end== 0) {
timeStr= start+ “万”;
} else {
timeStr= start+ “.” + end+ “万”;
}
return timeStr;
} else if (count<= 999 * 100000000) {
long start1= count/ 100000000;
long end1= count% 100000000 % 1000000;
if (end1== 0) {
timeStr= start1+ “亿”;
} else {
String s= String.valueOf(end1);
timeStr= start1+ “.” + s.charAt(0) + “亿”;
}
//return “999万+”;
} else if (count> 999 * 100000000) {
return “999.9亿+”;
}
return timeStr;
}
“`
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/hz/123736.html