我正在使用以下代码来格式化双数
DecimalFormat decimalFormat=new DecimalFormat("#.##");
decimalFormat.format(1.04)
但这给出了
java.lang.NumberFormatException: For input string: "1,04"
在 Linux 中 - 但在 Windows 7 中这工作正常,如何纠正这个问题?
最佳答案
关于 java 数字格式,这里似乎回答了一个非常相似的问题(DecimalFormat and Double.valueOf())。基本上,您遇到的差异可能与 Windows 上定义的区域设置与 Linux 上的区域设置不同有关(例如:在 Windows 上,您将其配置为与 Linux 不同的国家/语言)。
关于Java 数字格式 - #.## - Windows 和 Linux,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7643141/