]> git.ktnx.net Git - mobile-ledger.git/commitdiff
global function for formatting numbers (locale-aware)
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 29 Jan 2021 05:26:57 +0000 (05:26 +0000)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 29 Jan 2021 11:27:04 +0000 (11:27 +0000)
app/src/main/java/net/ktnx/mobileledger/model/Data.java

index f0f3987789e56673285923eee2209dc915d10b13..4d0e52a57eb2ecc09ff2fb8f34b097bf206f858b 100644 (file)
@@ -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<MobileLedgerProfile> observer) {
         profile.observe(lifecycleOwner, observer);