java将yyyyMMddHHmmss格式转换为yyyy-MM-dd HH:mm:ss

public static void main(String[] args) {
        String date = "20151101095440";

        String reg = "(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})";
        date = date.replaceAll(reg, "$1-$2-$3 $4:$5:$6");
        System.out.println(date);
    }

 

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页