[#1139] Malformed pattern for ICU DecimalFormat
- This handles possible malformed format pattern exceptions in Zashi, but the proper solution needs to be provided within the SDK. See #1315. - Closes #1139
This commit is contained in:
parent
90c982ac2a
commit
c901a63d54
|
@ -2,6 +2,7 @@
|
|||
|
||||
package cash.z.ecc.sdk.extension
|
||||
|
||||
import cash.z.ecc.android.sdk.internal.Twig
|
||||
import cash.z.ecc.android.sdk.model.MonetarySeparators
|
||||
import cash.z.ecc.android.sdk.model.PercentDecimal
|
||||
import java.math.RoundingMode
|
||||
|
@ -16,6 +17,10 @@ private fun preparePercentDecimalFormat(): DecimalFormat =
|
|||
DecimalFormat().apply {
|
||||
val monetarySeparators = MonetarySeparators.current()
|
||||
val localizedPattern = "##0${monetarySeparators.decimal}00"
|
||||
applyLocalizedPattern(localizedPattern)
|
||||
runCatching {
|
||||
applyLocalizedPattern(localizedPattern)
|
||||
}.onFailure {
|
||||
Twig.error(it) { "Failed on applying localized pattern" }
|
||||
}
|
||||
roundingMode = RoundingMode.HALF_UP
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue