Updated on 2026-08-14

This commit is contained in:
Tangem 2023-01-11 11:18:19 +03:00
commit 4516a76ad3
15 changed files with 322 additions and 124 deletions

View file

@ -0,0 +1,21 @@
package com.tangem.utils
import java.math.BigDecimal
import java.math.RoundingMode
import java.text.DecimalFormat
import java.text.DecimalFormatSymbols
import java.util.*
fun BigDecimal.toFormattedString(
decimals: Int, roundingMode: RoundingMode = RoundingMode.DOWN, locale: Locale = Locale.US,
): String {
val symbols = DecimalFormatSymbols(locale)
val df = DecimalFormat().apply {
decimalFormatSymbols = symbols
maximumFractionDigits = decimals
minimumFractionDigits = 0
isGroupingUsed = false
this.roundingMode = roundingMode
}
return df.format(this)
}