gpt4 book ai didi

Java 数字格式 - #.## - Windows 和 Linux

转载 作者:可可西里 更新时间:2023-11-01 11:21:38 25 4
gpt4 key购买 nike

我正在使用以下代码来格式化双数

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com