Reputation: 99
I'm Developing an app that fetches data from JSON. I want to set the int number into TextView in Formatted Way. I used Java java.text.NumberFormat for Formating.I want data to be Like 100000 = 1,00,000.
But This Giving error
java.lang.IllegalArgumentException: Cannot format given Object as a Number
Here is my code
String myString = NumberFormat.getCurrencyInstance().format(jsonObject.getString("cases"));
totalCasesNum.setText(myString);
Upvotes: 0
Views: 290
Reputation: 4377
Try this:
String myString = NumberFormat.getCurrencyInstance().format(Integer.parseInt(jsonObject.getString("cases"));
Upvotes: 1