decimal变量获取

import java.math.BigDecimal;
import java.math.BigInteger;

/**
 * decimal变量获取
 */
public class DecimalUtil {

    /**
     * 获取object的值
     *
     * @author fengshuonan
     * @Date 2019-04-04 17:07
     */
    public static Long getLong(Object object) {
        if (object == null) {
            return null;
        }
        if (object instanceof BigDecimal) {
            return ((BigDecimal) object).longValue();
        }
        if (object instanceof BigInteger) {
            return ((BigInteger) object).longValue();
        }
        if (object instanceof Long) {
            return ((Long) object);
        }
        return null;
    }

}

发布了156 篇原创文章 · 获赞 8 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/weixin_42590334/article/details/103455208