|
|
@@ -24,7 +24,7 @@ public class NumFormat {
|
|
|
public static Double getOne(Double result) {
|
|
|
DecimalFormat df = new DecimalFormat("#.0");
|
|
|
if (StringUtils.isEmpty(result)) {
|
|
|
- return 0.00;
|
|
|
+ return 0.0;
|
|
|
} else {
|
|
|
return Double.parseDouble(df.format(result));
|
|
|
}
|
|
|
@@ -39,11 +39,12 @@ public class NumFormat {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static String getPercent(Double result) {
|
|
|
- NumberFormat nt = NumberFormat.getPercentInstance();
|
|
|
+ public static Double getPercent(Double result) {
|
|
|
//设置百分数精确度2即保留两位小数
|
|
|
- nt.setMinimumFractionDigits(2);
|
|
|
- return nt.format(result);
|
|
|
+ DecimalFormat dfPercent = new DecimalFormat("##.00%");
|
|
|
+ String resultStr = dfPercent.format(result);
|
|
|
+ String needStr = resultStr.substring(0, resultStr.length() - 1);
|
|
|
+ return getTwo(Double.valueOf(needStr));
|
|
|
}
|
|
|
|
|
|
public static java.sql.Date getTwoYear() {
|
|
|
@@ -72,7 +73,7 @@ public class NumFormat {
|
|
|
return new java.sql.Date(ca.getTime().getTime());
|
|
|
}
|
|
|
|
|
|
- public static String getIncrease(Double last, Double now) {
|
|
|
+ public static Double getIncrease(Double last, Double now) {
|
|
|
if ((last != 0.0) && (now != 0.0)) {
|
|
|
return NumFormat.getPercent(now / last - 1);
|
|
|
}
|
|
|
@@ -82,7 +83,7 @@ public class NumFormat {
|
|
|
if (last != 0.0 && now == 0.0) {
|
|
|
return NumFormat.getPercent(-last);
|
|
|
}
|
|
|
- return "0%";
|
|
|
+ return 0.0;
|
|
|
}
|
|
|
|
|
|
public static java.sql.Date getThreeM() {
|