I have custom DecimalFormat
in Edittext\'s addTextChangedListener method, everything is working perfectly but when I change language (locale) my addTextChanged
Use simply this method to convert current localization wise number,
public static String currencyFormatter(String balance) {
try {
double amount = Double.parseDouble(balance);
DecimalFormat decimalFormat = new DecimalFormat("##,##,##,###.##");
DecimalFormat locationSpecificDF = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
locationSpecificDF = (DecimalFormat) DecimalFormat.getNumberInstance(Locale.forLanguageTag("bn")); // Ex. en, bn etc.
} else {
return decimalFormat.format(amount);
}
return locationSpecificDF.format(amount);
} catch (Exception e) {
return balance;
}
}
or follow this link.