当double的值太大的时候,比如1000000000
用DecimalFormat: double d = 1.0E7; System.out.println(new DecimalFormat("#").format(d));
根据小数点位数补0
/**取小数点位数补0 * セルの書式(Format) * @param webFilePath */ private String SetFormat(double maxValue){ Integer Maxlenth = 0; StringBuilder value = new StringBuilder(); if(maxValue !=0){ DecimalFormat decimalFormat = new DecimalFormat("###############.########"); String strmaxValue = decimalFormat.format(maxValue); String strpoint[] = strmaxValue.split("\."); if(strpoint.length >0){ int aaa = strpoint[1].length(); //Maxlenth = (maxValue+"").length()-(maxValue+"").indexOf(".")-1; Maxlenth = aaa; } } if(Maxlenth > 0 ){ for (int j = 0; j < Maxlenth; j++) { if(j==0){ value.append(".0"); }else{ value.append("0"); } } } return value.toString(); }