将字符串格式yyyyMMdd的字符串转为日期,格式“yyyy-MM-dd“

    技术2022-07-10  123

    将字符串格式yyyy/MM/dd的字符串转为日期,格式"yyyy-MM-dd"

    public static String strToDateFormat(String date) throws ParseException { SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd"); formatter.setLenient(false); Date newDate= formatter.parse(date); formatter = new SimpleDateFormat("yyyy-MM-dd"); return formatter.format(newDate); }
    Processed: 0.014, SQL: 10