实现从Java String字符串到BigDecimal的安装转换:
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParsePosition;
import java.util.Locale;
/**
* @Auther:四个空格-https://www.yomige.org/
*/
public class DecimalFormatExample {
public static void main(String[] args) {
String numStr = "1,000,000,000.999999999999999";
//Locale in_ID = new Locale("en","US");
//DecimalFormat nf = (DecimalFormat) NumberFormat.getInstance(in_ID);
DecimalFormat nf = (DecimalFormat) NumberFormat.getInstance();
nf.setParseBigDecimal(true);
BigDecimal bd = (BigDecimal) nf.parse(numStr, new ParsePosition(0));
System.out.println("bd value : " + bd);
}
}
参考:https://stackoverflow.com/questions/3752578/safe-string-to-bigdecimal-conversion;
最新评论
不错挺好用的,东至梅城何红涛林场的 何红涛2个月前 (10-18)回复
识别码不对
呵呵
我的是ipv4网络,如何使用直播源啊!