Java 手机号码格式化为182****5716
作者:互联网
/**
* 手机号码格式化微182****5716
*
* @param phone
* @return
*/
public static String phoneNumberFormat(String phone) {
String reStr = phone.substring(phone.length() - 4, phone.length());
String preStr = phone.substring(0, phone.length() - 9);
StringBuilder sb = new StringBuilder();
sb.append(preStr).append("****").append(reStr);
return sb.toString();
}
/**
* 银行账号格式化
*
* @param str
* @return
*/
public static String getSubString(String str) {
String reStr = str.substring(str.length() - 4, str.length());
return "尾号" + reStr;
}
标签:Java,String,5716,182,phone,length,str,reStr,return 来源: https://blog.51cto.com/10983206/2564148