suvendu pradhan
suvendu pradhan

Reputation: 49

format numeric currency to textual Indian number format Android

I have some numbers like 100,000 and I want to output as 1 Lakh in Indian numbering system. is there any method that supports it?

Detailed Example:

Input 5,50,000

Output 5.5 Lakh

Upvotes: 0

Views: 658

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521279

You could try stripping the commas, casting to an integer, the dividing to get the number of Lakhs:

DecimalFormat df = new DecimalFormat("#.#####");
String input = "5,50,000";
double lakhs = Double.parseDouble(input.replaceAll(",", "")) / 100000;
String out = df.format(lakhs);
System.out.println(out);

Demo

Upvotes: 1

Related Questions