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);
}
}
本文地址:http://com.8s8s.com/it/it17460.htm