package com.yihu.jw.util.common;

import java.text.DecimalFormat;
import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/9/9
 * @Description:
 */
public class StringUtil {

    public static String randomInt(int length) {
        String str = "0123456789";
        StringBuffer buffer = new StringBuffer();
        Random random = new Random();

        for(int i = 0; i < length; ++i) {
            int pos = random.nextInt(str.length());
            buffer.append(str.charAt(pos));
        }

        return buffer.toString();
    }

    /**
     * 2数相除保留1位小数
     * @param a
     * @param b
     * @return
     */
    public static String division(int a,int b){
        String result = "";
        float num =(float)a/b;
        DecimalFormat df = new DecimalFormat("0.0");
        result = df.format(num);
        return result;
    }

}
