package com.qmth.teachcloud.common.util.excel.convertor.impl;

import java.math.BigDecimal;

import org.apache.poi.ss.usermodel.Cell;

import com.qmth.teachcloud.common.util.excel.convertor.ValueConvertor;
import com.qmth.teachcloud.common.util.excel.model.FieldParam;

public class BigDecimalConvertor implements ValueConvertor<BigDecimal> {

    public static final BigDecimalConvertor instance = new BigDecimalConvertor();

    @Override
    public BigDecimal parse(String value, FieldParam param) throws Exception {
        return new BigDecimal(value);
    }

    @Override
    public void format(BigDecimal object, FieldParam param, Cell cell) throws Exception {
        cell.setCellValue(object.stripTrailingZeros().toString());
    }
}
