double类型取小数位数
1. BigDecimal 结果为double
double result =countByTime / countIsAccept;
BigDecimal bd = new BigDecimal(result);
double averageCycle = bd.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
2. NumberFormat 结果为String
import java.text.DecimalFormat;
import java.text.NumberFormat;
double a=10000;//要用double型,要不a/b永远得0;
double b=20000;
NumberFormat nbf=NumberFormat.getInstance();
nbf.setMinimumFractionDigits(2);
String c = nbf.format(a/b);