Skip to content
Snippets Groups Projects
Unverified Commit 176205bd authored by Lukas Lechner's avatar Lukas Lechner Committed by GitHub
Browse files

7 day r value decimal place issue (EXPOSUREAPP-4751) #2216


* Fix issue of cutting off decimal place .00 in statistics cards

* Fix number formatting issue when decimal value is 3

* Fix number formatting issue for values below zero

Co-authored-by: default avatarRalf Gehrer <ralfgehrer@users.noreply.github.com>
parent 442c4e0c
No related branches found
No related tags found
No related merge requests found
...@@ -22,7 +22,8 @@ fun formatStatisticalValue( ...@@ -22,7 +22,8 @@ fun formatStatisticalValue(
return when (decimals) { return when (decimals) {
in Int.MIN_VALUE..0 -> DecimalFormat("#,###", DecimalFormatSymbols(locale)) in Int.MIN_VALUE..0 -> DecimalFormat("#,###", DecimalFormatSymbols(locale))
1 -> DecimalFormat("#,###.0", DecimalFormatSymbols(locale)) 1 -> DecimalFormat("#,##0.0", DecimalFormatSymbols(locale))
else -> DecimalFormat("#,###.##", DecimalFormatSymbols(locale)) 2 -> DecimalFormat("#,##0.00", DecimalFormatSymbols(locale))
else -> DecimalFormat("#,##0.000", DecimalFormatSymbols(locale))
}.format(value) }.format(value)
} }
...@@ -56,6 +56,11 @@ internal class StatisticsNumberValueFormatterTest { ...@@ -56,6 +56,11 @@ internal class StatisticsNumberValueFormatterTest {
Arguments.of(12.3456, 2, Locale.GERMANY, "12,35"), Arguments.of(12.3456, 2, Locale.GERMANY, "12,35"),
Arguments.of(1.0036, 1, Locale.GERMANY, "1,0"), Arguments.of(1.0036, 1, Locale.GERMANY, "1,0"),
Arguments.of(1.0036, 2, Locale.GERMANY, "1,00"),
Arguments.of(1.0, 3, Locale.GERMANY, "1,000"),
Arguments.of(0.94, 1, Locale.GERMANY, "0,9"),
Arguments.of(0.95, 2, Locale.GERMANY, "0,95"),
Arguments.of(12.3456, 1, Locale.UK, "12.3"), Arguments.of(12.3456, 1, Locale.UK, "12.3"),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment