cerulean

          DateFormat setLenient

          之前都沒注意過有這么個方法,否則判斷日期格式就太不靠譜了。
          又是晦澀的單詞:setLenient(false),嚴(yán)格匹配日期格式
                  SimpleDateFormat df = new SimpleDateFormat("MMddyyyy");
                  
          /*
                   * With lenient parsing, the parser may use heuristics to interpret inputs that 
                   * do not precisely match this object's format. 
                   * With strict parsing, inputs must match this object's format. 
                   
          */
                  df.setLenient(
          false);
                  
          try {
                      Date a 
          = df.parse("23232011");
                      System.out.print(
          "date: " + a);
                  } 
          catch (java.text.ParseException e) {
                      
          // TODO Auto-generated catch block
                      e.printStackTrace();
                  }

          posted on 2011-07-18 17:23 cerulean 閱讀(3210) 評論(0)  編輯  收藏 所屬分類: Java

          導(dǎo)航

          <2011年7月>
          262728293012
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

          統(tǒng)計

          常用鏈接

          留言簿(3)

          隨筆分類

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 孝昌县| 诸暨市| 镇远县| 本溪市| 肥西县| 巴楚县| 花垣县| 阳原县| 红安县| 丹巴县| 台南县| 桓台县| 上林县| 会东县| 商南县| 桓仁| 三原县| 兴海县| 漾濞| 象州县| 江门市| 武穴市| 安平县| 宣武区| 保山市| 若尔盖县| 汝州市| 新巴尔虎左旗| 沛县| 开阳县| 东乌珠穆沁旗| 漠河县| 雅江县| 和平区| 齐齐哈尔市| 宾川县| 门源| 饶阳县| 金门县| 新蔡县| 榆林市|