package com.foreverwin.mesnac.common.export;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;

import java.math.BigDecimal;
import java.text.DecimalFormat;

public class BigDecimalConvert implements ColumnConvert {
    @Override
    public String convert(JSONObject row, String column, String value) {
        if (StrUtil.isBlank(value)) return "0";
        //--------------------------------------------------------------------------------------------------------
        try {
            DecimalFormat df = new DecimalFormat("0.0000");
            return df.format(new BigDecimal(value));
        } catch (Exception e) {
            ;
        }//try
        //--------------------------------------------------------------------------------------------------------
        return value;
    }
}
