欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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

程序员文章站 2022-04-03 22:25:41
...
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);
    }

 

相关标签: 时间格式转换