java String类型的数字日期转为时间格式的

  	String time = "20190712101011";
    String reg = "(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})";
    time = time.replaceAll(reg, "$1-$2-$3 $4:$5:$6");
    Date date=null;
    SimpleDateFormat formatter=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    date=formatter.parse(time);
    System.out.println(formatter.format(date));

你可能感兴趣的:(JAVA,java,date)