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) {undefined
String reStr = str.substring(str.length() - 4, str.length());
return "尾号" + reStr;
}
欢迎关注公众号:Java后端技术全栈