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

com.jirvan.jackson.TwoDecimalPlaceDeserializer Maven / Gradle / Ivy

The newest version!
package com.jirvan.jackson;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.deser.std.NumberDeserializers;

import java.io.IOException;
import java.math.BigDecimal;

public class TwoDecimalPlaceDeserializer extends NumberDeserializers.BigDecimalDeserializer {

    @Override
    public BigDecimal deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
        BigDecimal value = super.deserialize(p, ctxt);
        return value == null ? null
                             : value.setScale(2, BigDecimal.ROUND_UNNECESSARY);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy