Reputation: 47
I am working on a project that requires me to parse a String into an Integer. I have not had this problem before, but when I try to parse a String to an Integer, I get this message
Exception in thread "main" java.lang.NumberFormatException: For input string: "385.3100"
, where 385.3100 is the integer in question. Nothing I have done is working.
String close = (closing.get("4. close").toString()); int money = Integer.parseInt(close);
Is my code, where closing is a JSONObject.
Any help would be appreciated!
Upvotes: 0
Views: 89
Reputation: 379
385.3100 is not an integer but a number with decimal precision. Use:
Double.parseDouble()
or
Float.parseFloat()
Upvotes: 1