我在做 swing  进行 验证 时 需要 一个 yyyy-MM-dd HH:mm:ss  格式的正则表达式  ,  网上有很多版本但发现都不对  ,  比如    /**
        * 判断输入的字符串是否满足时间格式 : yyyy-MM-dd HH:mm:ss
        * @param patternString 需要验证的字符串
        * @return 合法返回 true ; 不合法返回false
        */
       public static boolean isTimeLegal(String patternString) {
              
            Pattern a=Pattern.compile("^((\\d{2}(([02468][048])|([13579][26]))[\\-\\/\\s]?((((0?[13578])|(1[02]))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])))))|(\\d{2}(([02468][1235679])|([13579][01345789]))[\\-\\/\\s]?((((0?[13578])|(1[02]))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\-\\/\\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))(\\s((([0-1][0-9])|(2?[0-3]))\\:([0-5]?[0-9])((\\s)|(\\:([0-5]?[0-9])))))?$"); 
            Matcher b=a.matcher(patternString); 
            if(b.matches()) {
                  return true;
            } else {
                  return false;
            }
       }  
 中的 ,  如果输入 为  2008-8-9 0:0:0  还是会通过,因为后面有很多业务在里面 ,必须进行  分、秒 、小时....等的 验证,所以必须满足  2008-08-09 00:00:00 格式的,在线等,先谢谢了!