Luc*_*ssi 1 java formatting locale numbers biginteger
我搜索了很多,但没有帮助我:(假设我需要转换12.090.129.019.201.920.192.091.029.102.901.920.192.019.201.920(在葡萄牙语组分隔符:.)到BigInteger值.如何进行转换?我试过使用NumberFormat,DecimalFormat,没有任何作用或我没有正确的方式:(
获取NumberFormat葡萄牙语的实例Locale,然后获取该数字的实例parse.这也将处理特定于语言环境的小数分隔符.
NumberFormat nf = NumberFormat.getNumberInstance(new Locale("pt", "PT"));
DecimalFormat df = (DecimalFormat)nf;
df.setParseBigDecimal(true);
BigDecimal decimal = (BigDecimal)df.parse("12.090.129.019.201.920.192.091.029.102.901.920.192.019.201.920");
BigInteger big = decimal.toBigInteger();
Run Code Online (Sandbox Code Playgroud)
演示.