package com.hzs.common.core.utils;

import java.text.DecimalFormat;

/**
 * @Description:
 * @Author: yuhui
 * @Time: 2022/12/2 14:12
 * @Classname: NumberUtil
 * @PackageName: com.hzs.common.core.utils
 */
public class NumberUtil {

    /**
     * 获取百分比
     * @param number1 /
     * @param number2 总数/
     * @return java.lang.String /
     * @date 2022/5/30 14:48
     */
    public static String getRatio(Integer number1, Integer number2) {
        DecimalFormat df = new DecimalFormat("0.0");
        if (number2 != 0) {
            return df.format((float) (number1 / (double) number2) * 100) + "%";
        } else {
            return "0%";
        }
    }

}
