format number

format number 

 

public static String format(BigDecimal number) {

java.text.DecimalFormat format = new java.text.DecimalFormat("####.00");

number = number.setScale(2, BigDecimal.ROUND_HALF_UP);

return format.format(number.doubleValue());

}

 

public static String format(String number) {

return format(new BigDecimal(number));

}

 

public static String format(Double number) {

return format(new BigDecimal(number));

}


你可能感兴趣的:(java,UP)