1.第一种方法
public static void main(String[] args) throws ParseException {
String startDate = "2019-10-03";
//删除 字符串中的"-"
//找到字符串中的-字符的位置
int result = startDate .indexOf("-");
//把-前面的字符和-后边的字符再拼起来
String date = startDate .substring(0,result) + startDate .substring(result+1) ;
System.out.println(date);
输出 2020191003
}
2.第二种方法
public static void main(String[] args) throws ParseException {
String startDate = "2019-10-03";
//删除 字符串中的"-"
//把字符串中-都替换成空字符串
String date1 = startDate .replace("-","");
System.out.println(date1 );
输出 2020191003