Hello World
          Java技術學習
          posts - 17,  comments - 7,  trackbacks - 0
          最近頻頻使用日期方面的操作,總結了一下。以后可以參考

          得到當前時間
          ????SimpleDateFormat?df?=?new?SimpleDateFormat("yyyy-MM-dd?HH:mm:ss");
          ????String?currentTime?
          =?df.format(new?java.util.Date(System.currentTimeMillis()));

          得到上月時間
          GregorianCalendar?cal?=?new?GregorianCalendar();
          SimpleDateFormat?df?
          =?new?SimpleDateFormat("yyyy-MM-dd");
          cal.add(GregorianCalendar.MONTH,?
          -1);
          String?lastMonth?
          =??df.format(cal.getTime());

          得到某月開始時間和結束時間
          String?strm?=?"2006-10";
          SimpleDateFormat?df1?
          =?new?SimpleDateFormat("yyyy-MM");
          Date?tdate?
          =?df1.parse(strm);
          GregorianCalendar?cal?
          =?new?GregorianCalendar();
          cal.setTime(tdate);
          System.out.println(strm
          +"-"+cal.getActualMaximum(cal.DAY_OF_MONTH));
          System.out.println(strm
          +"-"+cal.getActualMinimum(cal.DAY_OF_MONTH));
          posted on 2006-10-20 15:26 Java初心 閱讀(400) 評論(0)  編輯  收藏 所屬分類: java

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


          網站導航:
           

          <2006年10月>
          24252627282930
          1234567
          891011121314
          15161718192021
          22232425262728
          2930311234

          常用鏈接

          留言簿(1)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 高密市| 虞城县| 潞城市| 慈利县| 禄劝| 玉田县| 扎赉特旗| 呼玛县| 洪江市| 玛曲县| 道真| 尉犁县| 攀枝花市| 屯昌县| 北安市| 睢宁县| 平谷区| 商水县| 苏尼特右旗| 盐城市| 嵩明县| 兰西县| 美姑县| 枞阳县| 深水埗区| 平顶山市| 禄丰县| 化隆| 保亭| 冀州市| 孙吴县| 政和县| 沾益县| 延长县| 贵德县| 阳高县| 台州市| 凌源市| 清徐县| 甘泉县| 揭西县|