A user of my app is having a error and the app is crashing
I've looked at the report and it's stating
Caused by: java.lang.NumberFormatException: Invalid double: "1,36"
I have reproduced the data inputted on my app and I don't have the issue at all
I have even asked her to send me her database so i can import the exact data and it still worked okay for me
I'm confused as to where the double is getting formatted like that as I can't see anywhere in my code where it would get formatted with a ,
Any suggestions as to what's going on?
Simple way is (do it above your parce):
if (str.contains(",")) {
str.replace(",",".");
}
I just have faced the same problem. I was converting float value to String. Yes, it must be a locale issue. As said in one of the comments, Some locales use , as a decimal separator. Initially I was converting float like-
String.format("%.1f", value);
Then I changed the code to
String.format(Locale.ENGLISH, "%.1f", value);
So, forcing the string to be converted with English local worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With