From: Damyan Ivanov Date: Fri, 29 Jan 2021 05:26:57 +0000 (+0000) Subject: global function for formatting numbers (locale-aware) X-Git-Tag: v0.17.0~205 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=6790483dc667a4a44f2c47a3cb61a8c952aa038b;p=mobile-ledger.git global function for formatting numbers (locale-aware) --- diff --git a/app/src/main/java/net/ktnx/mobileledger/model/Data.java b/app/src/main/java/net/ktnx/mobileledger/model/Data.java index f0f39877..4d0e52a5 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/Data.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/Data.java @@ -190,7 +190,10 @@ public final class Data { else currencySymbolPosition.setValue(Currency.Position.none); } - + public static String formatNumber(float number) { + NumberFormat formatter = NumberFormat.getCurrencyInstance(locale.getValue()); + return formatter.format(number); + } public static void observeProfile(LifecycleOwner lifecycleOwner, Observer observer) { profile.observe(lifecycleOwner, observer);