成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

Java基于正則實(shí)現(xiàn)的日期校驗(yàn)功能示例-創(chuàng)新互聯(lián)

創(chuàng)新互聯(lián)www.cdcxhl.cn八線動態(tài)BGP香港云服務(wù)器提供商,新人活動買多久送多久,劃算不套路!

江津ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為成都創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18980820575(備注:SSL證書合作)期待與您的合作!

本文實(shí)例講述了Java基于正則實(shí)現(xiàn)的日期校驗(yàn)功能。分享給大家供大家參考,具體如下:

private void checkDate() throws IOException {
    // 4種分隔符
    String sep = "[-\\./_]";
    // 年份
    String strPattern = "^(19[4-9]\\d|20\\d{2})" + sep;
    strPattern += "(";
    // 月(1,3,5,7,8,10,12)
    strPattern += "((0?[13578]|1[02])" + sep + "(0?[1-9]|[12][0-9]|3[01]))|";
    // 月(4,6,9,11)
    strPattern += "((0?[469]|11)" + sep + "(0?[1-9]|[12][0-9]|30))|";
    // 月(2)
    strPattern += "((2)" + sep + "(0?[1-9]|[12]\\d))";
    strPattern += ")$";
    Pattern p = Pattern.compile(strPattern);
    Matcher m = p.matcher("");
    int count = 0;
    String fileName = ExcelGene.class.getResource("date.txt").getFile();
    BufferedReader br = new BufferedReader(new FileReader(fileName));
    String line = null;
    while ((line = br.readLine()) != null) {
      count++;
      if (line.trim().length() > 0) {
        m.reset(line);
        if (!m.find()) {
          System.out.println(count + " " + line);
        } else {
          String year = m.group(1);
          String month = m.group(4);
          month = month == null ? m.group(7) : month;
          month = month == null ? m.group(10) : month;
          String date = m.group(5);
          date = date == null ? m.group(8) : date;
          date = date == null ? m.group(11) : date;
          System.out.println(year + "年" + month + "月" + date + "日");
        }
      }
    }
}

分享文章:Java基于正則實(shí)現(xiàn)的日期校驗(yàn)功能示例-創(chuàng)新互聯(lián)
標(biāo)題鏈接:http://jinyejixie.com/article30/csodso.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站內(nèi)鏈域名注冊、小程序開發(fā)商城網(wǎng)站、網(wǎng)站設(shè)計(jì)網(wǎng)站設(shè)計(jì)公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

營銷型網(wǎng)站建設(shè)
高尔夫| 佳木斯市| 土默特左旗| 正镶白旗| 闵行区| 民县| 通榆县| 和顺县| 和静县| 华宁县| 兴安县| 土默特左旗| 乌拉特后旗| 黄山市| 建湖县| 三原县| 阜新市| 新龙县| 军事| 集贤县| 安康市| 高邑县| 焦作市| 华池县| 木兰县| 无为县| 泗水县| 永丰县| 遂溪县| 新丰县| 邹城市| 宜都市| 舞阳县| 抚远县| 离岛区| 普格县| 南木林县| 大关县| 南漳县| 塘沽区| 五指山市|