0

In creating a Java project, I ran into an issue with the standard Java libraries. I was using a DecimalFormat to format a double (truncating it from 3.4555555 to 3.45, for example). This worked fine for me, but when I sent it to someone else, they were getting an exception every time they started it. I was able to figure out from the stack trace that the DecimalFormat was converting it to 3,45 instead of 3.45 due to their locale, and Double.parseDouble didn't account for that. For the time being, I'm doing .replace(",", ".") on the string being parsed, but I don't know if there are other number formats in other locales. Is there any method that accounts for locale in the same way a DecimalFormat does?

Redempt
  • 169
  • 1
  • 1
  • 9

0 Answers0