How can I guarantee that the decimal separator will always be "."

In the Polish regional definition, decimal separator,. In English it is . . There may be other delimiters in other languages. (There is?).

I want to use the BigDecimal String constructor when reading the input file. In my file I want to use . as a decimal separator.

How can I guarantee that I do not get a NumberFormatException if the decimal separator of the environment is not . ?

+4
source share
1 answer

BigDecimal constructor - like Double.parseDouble , etc. - always uses '.' as a decimal separator. It does not use the current culture at all, and there is no way to specify the format of the number.

(It would be nice if it were clearly documented, though ...)

+7
source

Source: https://habr.com/ru/post/1412984/


All Articles