java8时间 yyyyMMddHHmmss格式转为日期

String datetime =  "20140212111012";
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
        LocalDateTime ldt = LocalDateTime.parse(datetime,dtf);
        System.out.println(ldt);


        DateTimeFormatter fa = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String datetime2 = ldt.format(fa);
        System.out.println(datetime2);

你可能感兴趣的:(java文件)