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初心 閱讀(403) 評論(0)  編輯  收藏 所屬分類: java

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


          網站導航:
           

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

          常用鏈接

          留言簿(1)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 丹江口市| 平塘县| 永福县| 山阴县| 临泽县| 遂川县| 枝江市| 玛曲县| 三门县| 磐安县| 博罗县| 江门市| 东阿县| 社旗县| 淮安市| 通辽市| 安西县| 江门市| 闽侯县| 吴忠市| 谢通门县| 忻城县| 安达市| 兴隆县| 新乡市| 新源县| 鹰潭市| 巴马| 磐安县| 营山县| 繁昌县| 中山市| 临湘市| 竹北市| 怀远县| 石首市| 怀集县| 来凤县| 孝昌县| 儋州市| 老河口市|