package com.taover.easyexcel.converters.bigdecimal; import java.math.BigDecimal; import java.text.ParseException; import com.taover.easyexcel.converters.Converter; import com.taover.easyexcel.enums.CellDataTypeEnum; import com.taover.easyexcel.metadata.CellData; import com.taover.easyexcel.metadata.GlobalConfiguration; import com.taover.easyexcel.metadata.property.ExcelContentProperty; import com.taover.easyexcel.util.NumberUtils; /** * BigDecimal and string converter * * @author Jiaju Zhuang */ public class BigDecimalStringConverter implements Converter { @Override public Class supportJavaTypeKey() { return BigDecimal.class; } @Override public CellDataTypeEnum supportExcelTypeKey() { return CellDataTypeEnum.STRING; } @Override public BigDecimal convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws ParseException { return NumberUtils.parseBigDecimal(cellData.getStringValue(), contentProperty); } @Override public CellData convertToExcelData(BigDecimal value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) { return NumberUtils.formatToCellData(value, contentProperty); } }