zhyiwww
          用平實(shí)的筆,記錄編程路上的點(diǎn)點(diǎn)滴滴………
          posts - 536,comments - 394,trackbacks - 0
           

           

          轉(zhuǎn)換:

          從Date到String

          DateFormat df = new SimpleDateFormat("yyyy-MM-dd");

          Date d = new Date();

          String dstr = Df.format(d);

          從String到日期

          DateFormat df = new SimpleDateFormat("yyyy-MM-dd");

          Date d = df.parse("2014-02-19");

           

          從date到calendar

          Calendar cd1 = Calendar.getInstance();

          Date sd1 = df.parse(startDate);        

          cd1.setTime(sd1);

          如:

          startDate="2014-02-19";

          從calender到Date

          Calendar cd1 = Calendar.getInstance();

          Date d = cd1.getTime();

           

           

          格式化:

          格式化Date

          DateFormat df = new SimpleDateFormat("yyyy-MM-dd");

          String dstr = df.format(new Date());

          格式化Calendar

          DateFormat df = new SimpleDateFormat("yyyy-MM-dd");

          Calendar cd1 = Calendar.getInstance();

          String dstr = df.format(cd1.getTime());

          格式化日期字符串

          DateFormat df = new SimpleDateFormat("yyyy-MM-dd");

          Date d = df.parse("2014-02-19");

          DateFormat df1 = new SimpleDateFormat("MM-dd");

          String dstr2 = df1.format(d);

           

           



          |----------------------------------------------------------------------------------------|
                                     版權(quán)聲明  版權(quán)所有 @zhyiwww
                      引用請(qǐng)注明來源 http://www.aygfsteel.com/zhyiwww   
          |----------------------------------------------------------------------------------------|
          posted on 2014-02-19 18:20 zhyiwww 閱讀(804) 評(píng)論(0)  編輯  收藏 所屬分類: j2ee
          主站蜘蛛池模板: 恩施市| 阳东县| 白银市| 阜阳市| 财经| 建平县| 沅陵县| 台中县| 新建县| 芦溪县| 万源市| 南宁市| 华安县| 瓦房店市| 尚志市| 彭阳县| 辉县市| 陈巴尔虎旗| 治县。| 铜山县| 贵定县| 衡水市| 纳雍县| 墨玉县| 贵南县| 宜城市| 敦煌市| 左权县| 海盐县| 绥芬河市| 汝城县| 丹江口市| 勐海县| 普格县| 定边县| 青川县| 上栗县| 栾城县| 宜良县| 洛宁县| 四子王旗|