日期:2014-05-20 浏览次数:20833 次
public String getDecimalFormat(String str){
Integer initValue=0;
String outStr = "";
if(str!=null&&!"".equals(str.trim())){
initValue=Integer.parseInt(str);
Integer yuanValue=initValue/100;
DecimalFormat fmt = new DecimalFormat("##,###,###,###,###.00");
double d;
try {
d = Double.parseDouble(String.valueOf(yuanValue));
outStr = fmt.format(d);
} catch (Exception e) {
e.printStackTrace();
}
}
return outStr;
}
String str="10";
Double initValue=0D;
String outStr = "";
if(str!=null&&!"".equals(str.trim())){
initValue= Double.parseDouble(str);
Double yuanValue=initValue/100;
System.out.println(yuanValue);
DecimalFormat fmt = new DecimalFormat("##,###,###,###,###0.00");
double d;
try {
d = Double.parseDouble(String.valueOf(yuanValue));
outStr = fmt.format(d);
System.out.println(outStr);
} catch (Exception e) {
e.printStackTrace();
}
}
public static String getDecimalFormat(String str){
double initValue=0;
String outStr = "";
if(str!=null&&!"".equals(str.trim())){
initValue=Double.parseDouble(str);
double yuanValue=initValue/100; //用double不会丢掉小数点后面的