import Java.text.*;
public class UT {
private final static DecimalFormat nf = new DecimalFormat("###,##0.00");
public static String formatToMoney(String s) {
if (s == null || s.equals("")) {
return "0.00";
}
try {
return formatToMoney(Double.parseDouble(s));
} catch (Exception e) {
return s;
}
}
public static String formatToMoney(double d) {
try {
return nf.format(d);
} catch (Exception e) {
return String.valueOf(d);
}
}
public static void main(String[] args){
String dd=Client.formatToMoney("12345678990.78987");
System.out.println(dd);
}
}
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10748419/viewspace-988541/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/10748419/viewspace-988541/