Created
May 26, 2021 20:25
-
-
Save CharlesLuxinger/fccd2e020e1147b26b71c84d007faf7b to your computer and use it in GitHub Desktop.
BigDecimal To Decimal128 Mongo Converter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package br.com.soudonus.credit.port.config.converter | |
import java.math.BigDecimal | |
import java.math.RoundingMode | |
import org.bson.types.Decimal128 | |
import org.springframework.core.convert.converter.Converter | |
object BigDecimalToDecimal128Converter { | |
fun decimal128ToBigDecimal(): Converter<Decimal128, BigDecimal> = | |
Converter<Decimal128, BigDecimal> { decimal128 -> decimal128.bigDecimalValue() } | |
fun bigDecimalToDecimal128(): Converter<BigDecimal, Decimal128> = | |
Converter<BigDecimal, Decimal128> { bigDecimal -> Decimal128(bigDecimal.setScale(2, RoundingMode.HALF_EVEN)) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment