fun.bigtable.kraken.web.CustomDecimalSerialize Maven / Gradle / Ivy
package fun.bigtable.kraken.web;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
public class CustomDecimalSerialize extends JsonSerializer {
@Override
public void serialize(BigDecimal value, JsonGenerator gen, SerializerProvider serializers)
throws IOException, JsonProcessingException {
if (value != null) {
value = value.setScale(2, RoundingMode.HALF_UP);
gen.writeString(value.toString());
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy