From 6790483dc667a4a44f2c47a3cb61a8c952aa038b Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Fri, 29 Jan 2021 05:26:57 +0000 Subject: [PATCH] global function for formatting numbers (locale-aware) --- app/src/main/java/net/ktnx/mobileledger/model/Data.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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); -- 2.39.5