+ else
+ currencySymbolPosition.setValue(Currency.Position.none);
+
+ NumberFormat newNumberFormatter = NumberFormat.getNumberInstance();
+ newNumberFormatter.setParseIntegerOnly(false);
+ newNumberFormatter.setGroupingUsed(true);
+ newNumberFormatter.setGroupingUsed(true);
+ newNumberFormatter.setMinimumIntegerDigits(1);
+ newNumberFormatter.setMinimumFractionDigits(2);
+
+ numberFormatter = newNumberFormatter;
+ }
+ public static String formatCurrency(float number) {
+ NumberFormat formatter = NumberFormat.getCurrencyInstance(locale.getValue());
+ return formatter.format(number);
+ }
+ public static String formatNumber(float number) {
+ return numberFormatter.format(number);
+ }
+ public static void observeProfile(LifecycleOwner lifecycleOwner, Observer<Profile> observer) {
+ profile.observe(lifecycleOwner, observer);
+ }
+ public static void removeProfileObservers(LifecycleOwner owner) {
+ profile.removeObservers(owner);
+ }
+ public static float parseNumber(String str) throws ParseException {
+ ParsePosition pos = new ParsePosition(0);
+ Number parsed = numberFormatter.parse(str);
+ if (parsed == null || pos.getErrorIndex() > -1)
+ throw new ParseException("Error parsing '" + str + "'", pos.getErrorIndex());