package com.clx.performance.utils;

import java.math.BigDecimal;

/**
 * @ClassName MoneyConvertUtils
 * @Description 金额转换工具类
 * @Author kavin
 * @Date 2023/9/17 16:10
 * @Version 1.0
 */
public class MoneyConvertUtils {
    /**
     * @Author kavin
     * @Description 元转分
     * @Param [data, exp]
     * @return
     **/
    public static BigDecimal convertCent(BigDecimal data) {
        return convert(data,2);
    }
    public static BigDecimal convert(BigDecimal data, int exp) {
        if (data == null) {
            return null;
        }
        return exp == 0 ? data : (exp < 0 ? data.movePointRight(-exp) : data.movePointLeft(exp));
    }

}
