package jnpf.util;

import jnpf.exception.HandleException;

/**
 * 数字转换类
 *
 * @author yanwenfu
 * @create 2025-04-17
 */
public class NumberUtils {

    public static float safeToFloat(Object obj) throws HandleException {
        if (obj instanceof Number) {
            Number num = (Number) obj;
            return num.floatValue();
        }
        try {
            return Float.parseFloat(String.valueOf(obj));
        } catch (NumberFormatException e) {
            throw new HandleException("转换失败");
        }
    }
}
