/**
* 正则表达式字符串替换
* @param content 字符串
* @param pattern 正则表达式
* @param newString 新的替换字符串
* @return 返回替换后的字符串
*/
public static String regReplace(String content,String pattern,String newString){
Pattern p = Pattern.compile(pattern);
Matcher m = p.matcher(content);
String result = m.replaceAll(newString);
return result;
}
System.out.println(regReplace("2020-12-12 15:03:06","[0-9][0-9]:","00:"));
2020-12-12 00:00:06