日期格式为“YYYYMM”的正则表达式

 public static boolean verifyYYYYMM(String date){
        String regex = "^(20|19){1}[0-9]{2}(((0){1}[1-9]{1})|((1){1}(0|1|2){1}))$";
        boolean matches =  Pattern.matches(regex, date);
        System.out.println(matches);
        return matches;
    }
posted @ 2020-10-20 17:08  《》  阅读(3193)  评论(0编辑  收藏  举报