在法国的机器上执行时出现java.lang.NumberFormatException [英] java.lang.NumberFormatException while executing in France machine
本文介绍了在法国的机器上执行时出现java.lang.NumberFormatException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在下面的代码中,有时在解析值时我在法国计算机上遇到NumberFormat异常.
In below code while parsing the value sometimes i am facing NumberFormat Exception in France machine.
double txPower;
DecimalFormat df = new DecimalFormat("##.##");
txPower = txPower + getDeltaP();
log.info("txpower value is -- "+txPower);
txPower = Double.parseDouble(df.format(txPower));
protected double getDeltaP()
{
return isNewChannelAddition ? apaConfig.deltaPadd : apaConfig.deltaPtune;
}
日志:
txpower value is -- -7.9
java.lang.NumberFormatException: For input string: "-7,9"
推荐答案
我建议使用配置为您的语言环境默认值的十进制分隔符.
I suggest to use the decimal separator configured as default for your locale.
new DecimalFormatSymbols(Locale.getDefault(Locale.Category.FORMAT)).getDecimalSeparator();
这篇关于在法国的机器上执行时出现java.lang.NumberFormatException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文