Skip to content

Commit f0e5648

Browse files
committed
show 0 balance with decimals in classic denomination
1 parent 24be4bc commit f0e5648

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

app/src/main/java/to/bitkit/models/Currency.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,16 @@ fun Long.formatToModernDisplay(locale: Locale = Locale.getDefault()): String {
106106
fun ULong.formatToModernDisplay(locale: Locale = Locale.getDefault()): String = toLong().formatToModernDisplay(locale)
107107

108108
fun Long.formatToClassicDisplay(locale: Locale = Locale.getDefault()): String {
109-
val sats = this
110109
val symbols = DecimalFormatSymbols(locale).apply {
111110
decimalSeparator = DECIMAL_SEPARATOR
112111
}
113-
val formatter = DecimalFormat("###.########", symbols)
114-
return formatter.format(sats.asBtc())
112+
val pattern = "0.${"0".repeat(CLASSIC_DECIMALS)}"
113+
val formatter = DecimalFormat(pattern, symbols).apply {
114+
minimumFractionDigits = CLASSIC_DECIMALS
115+
maximumFractionDigits = CLASSIC_DECIMALS
116+
isGroupingUsed = false
117+
}
118+
return formatter.format(asBtc())
115119
}
116120

117121
fun BigDecimal.formatCurrency(decimalPlaces: Int = FIAT_DECIMALS, locale: Locale = Locale.getDefault()): String? {

0 commit comments

Comments
 (0)