标签:index mount ret contain string nta contains substr one
``` /*
*货币 元 转换为 分
*/
public static Long formatMoney(String s){
if(s.contains(".")){
int index = s.indexOf(".");
String sub1 = s.substring(0,index);
String sub2 = s.substring(index+1);
if(sub2.length()>2){
sub2 = sub2.substring(0,2);
}
while(sub2.length()<2){
sub2=sub2+"0";
}
s = sub1+sub2;
}else{
s=s+"00";
}
Long amount = Long.parseLong(s);
return amount;
}
标签:index mount ret contain string nta contains substr one
原文地址:https://blog.51cto.com/brightaries/2517071