人数,点赞统计(>9999人时,显示为1.00万人)

来源:互联网 发布:域名别名是什么 编辑:程序博客网 时间:2024/05/02 19:38
    /**
     * 人数統計
     *
     * @param count
     * @return
     */
    public String renCount(long count, Context context) {
        String str;
        if (count > 9999) {
            str = getCountByMillionUnit(count) +"万人";
        } else {
            str = String.valueOf(count) + "人";
        }

        return str;

    }


    public String getCountByMillionUnit(long number){
        String str;
        if (number > 9999) {
            long temp1 = number / 10000;
            long temp2 = number % 10000;
            long temp3 = temp2 / 1000;
            if(temp3 == 0){
                str = String.valueOf(temp1);
            }else{
                str = String.valueOf(temp1)+"."+String.valueOf(temp3);
            }
        } else {
            str = String.valueOf(number);
        }
        return str;
    }

0 0
原创粉丝点击