隨筆-60  評論-35  文章-15  trackbacks-0
          ????????GregorianCalendar?cal? = ? new ?GregorianCalendar();
          ????????Date?now?
          = ? new ?Date();
          ????????cal.setTime(now);
          ????????cal.setFirstDayOfWeek(GregorianCalendar.MONDAY);??
          // 設置一個星期的第一天為星期1,默認是星期日
          ????????SimpleDateFormat?dateutil? = ? new ?SimpleDateFormat( " yyyy-MM-dd " );
          ????????System.out.println(
          " now= " + dateutil.format(cal.getTime()));? // 今天
          ????????
          ????????cal.add(GregorianCalendar.DATE,
          - 1 );
          ????????System.out.println(
          " now= " + dateutil.format(cal.getTime())); // 昨天????????
          ????????
          ????????cal.set(GregorianCalendar.DAY_OF_WEEK,?GregorianCalendar.MONDAY);
          ????????System.out.println(
          " now= " + dateutil.format(cal.getTime()));?? // 本周1

          ????????cal.set(GregorianCalendar.DAY_OF_MONTH,?
          1 );?
          ????????System.out.println(
          " now= " + dateutil.format(cal.getTime())); // 本月1日
          posted on 2006-09-24 19:15 Q系列類、方法、變量…… 閱讀(1560) 評論(1)  編輯  收藏

          評論:
          # re: 獲得本月一日、本星期星期一、昨天的date對象的方法 2006-09-25 08:32 | 壞男孩
          java的一本書上好像叫《Java 2參考大全(第五版)》上面有這些基礎的東西,學習java基礎的同仁很適合看那本書,推薦樓主去買啊!  回復  更多評論
            

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          <2006年9月>
          272829303112
          3456789
          10111213141516
          17181920212223
          24252627282930
          1234567

          常用鏈接

          留言簿(2)

          隨筆檔案

          文章分類

          文章檔案

          相冊

          優秀文章、知識

          電子書下載

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 阿鲁科尔沁旗| 贵阳市| 府谷县| 桐柏县| 新泰市| 杭锦旗| 花莲市| 乳山市| 弥渡县| 修武县| 中西区| 双峰县| 灵台县| 金塔县| 沁水县| 长兴县| 桐庐县| 延津县| 高密市| 德安县| 栾城县| 梁河县| 桐庐县| 黄骅市| 西林县| 龙口市| 和田县| 常德市| 调兵山市| 三原县| 开阳县| 灌南县| 前郭尔| 三台县| 武强县| 杨浦区| 延津县| 威远县| 会泽县| 香港 | 永寿县|