json 百分比转化

NumberFormat number = NumberFormat.getPercentInstance();
number.setMaximumFractionDigits(0);//设置小数点后几位  
double answerDurPre15Double = Double.parseDouble(vo.getAnswerDurPre15());
double answerDurPre20Double = Double.parseDouble(vo.getAnswerDurPre20());
String answerDurPre15 =number.format(answerDurPre15Double);
String answerDurPre20 =number.format(answerDurPre20Double);
vo.setAnswerDurPre15(answerDurPre15);
vo.setAnswerDurPre20(answerDurPre20);

NumberFormat number = NumberFormat.getPercentInstance();
number.setMaximumFractionDigits(0);//设置小数点后几位  
double goodProportionDouble = Double.parseDouble(obj.get("messageProportion").toString()); //转化为double
// int messageProportionInt = Integer.parseInt(obj.get("messageProportion").toString());
String messageProportion =number.format(goodProportionDouble);
exportData.setDxcyprecent(messageProportion);

猜你喜欢

转载自www.cnblogs.com/gzl180110/p/10530054.html