package com.yida.data.common.core.utils;

public class NumberUtil {

    /**
     * 格式化double数字
     *
     * @param pattern
     * @param number
     * @return
     */
    public static Double format(String pattern, Double number) {
        return Double.valueOf(cn.hutool.core.util.NumberUtil.decimalFormat(pattern, number));
    }

    /**
     * object转long
     */
    public static Long object2Long(Object target) {
        Long res = null;
        if (target != null) {
            res = Long.valueOf(target.toString());
        }
        return res;
    }

    /**
     * 16进制转2进制串
     *
     * @param hexStr
     * @return
     */
    public static String hexTobinay(String hexStr) {
        Long value = Long.valueOf("FFFFFFFF", 16);
        String s = Long.toBinaryString(value);
        return s;
    }
}
