/**
* 格式化金额,保留两位小数,即精确到分
* @param balance 身份证
* @return
*/
public static String formatBalance(String balance){
if(balance == null) {
return null;
}
if("0".equals(balance)) {
return "0.00";
}
if("0.0".equals(balance)) {
return "0.00";
}
if(balance.indexOf(".")<0){
return balance+".00";
}
String[] balanceArray=balance.split("\\.");
if(balanceArray[1].length()==1){
return balanceArray[0]+"."+balanceArray[1].substring(0, 1)+"0";
}
return balanceArray[0]+"."+balanceArray[1].substring(0, 2);
}