All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.gjing.tools.excel.convert.DecimalConvert Maven / Gradle / Ivy

There is a newer version: 2021.12.3
Show newest version
package cn.gjing.tools.excel.convert;

import org.springframework.util.StringUtils;

import java.lang.reflect.Field;
import java.math.BigDecimal;

/**
 * Converts the string to a Java BigDecimal
 *
 * @author Gjing
 **/
public class DecimalConvert implements DataConvert {
    @Override
    public Object toEntityAttribute(Object value, Field field) {
        return StringUtils.isEmpty(value) ? BigDecimal.ZERO : new BigDecimal(value.toString());
    }

    @Override
    public Object toExcelAttribute(Object obj, Object value, Field field) {
        return value;
    }
}