From 4cb0b0649716c44e8dc1a0dcbeb7ab0da3867405 Mon Sep 17 00:00:00 2001 From: Milan Date: Tue, 27 Aug 2024 08:49:05 +0200 Subject: [PATCH] Currency conversion floating point hotfix (#1569) * Currency conversion floating point hotfix * Revert "Currency conversion floating point hotfix" This reverts commit 2a0774d4371b6f934abc7c7b02bf8f0027dfb088. * Currency conversion floating point hotfix * Currency conversion floating point hotfix --- .../z/ecc/android/sdk/model/ZatoshiExt.kt | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/sdk-incubator-lib/src/main/java/cash/z/ecc/android/sdk/model/ZatoshiExt.kt b/sdk-incubator-lib/src/main/java/cash/z/ecc/android/sdk/model/ZatoshiExt.kt index 47c96e221..caa111c59 100644 --- a/sdk-incubator-lib/src/main/java/cash/z/ecc/android/sdk/model/ZatoshiExt.kt +++ b/sdk-incubator-lib/src/main/java/cash/z/ecc/android/sdk/model/ZatoshiExt.kt @@ -73,18 +73,10 @@ fun BigDecimal.convertFiatDecimalToFiatString( monetarySeparators: MonetarySeparators, includeSymbols: Boolean = true ): String { - val numberFormat = - if (includeSymbols) { - NumberFormat.getCurrencyInstance(locale) - } else { - NumberFormat.getInstance(locale) - } + val numberFormat = NumberFormat.getCurrencyInstance(locale) return numberFormat.apply { - if (includeSymbols) { - currency = fiatCurrency - } - + currency = fiatCurrency roundingMode = RoundingMode.HALF_EVEN if (this is DecimalFormat) { decimalFormatSymbols.apply { @@ -95,5 +87,11 @@ fun BigDecimal.convertFiatDecimalToFiatString( } } } - }.format(this) + }.format(this).let { + if (includeSymbols) { + it + } else { + it.replace(fiatCurrency.symbol, "").trim() + } + } }