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)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 平乐县| 海晏县| 江安县| 云南省| 区。| 阿尔山市| 稻城县| 盖州市| 樟树市| 灵璧县| 连江县| 东台市| 桂东县| 龙泉市| 开原市| 临猗县| 连南| 荥经县| 巨野县| 临朐县| 辛集市| 中卫市| 诸城市| 高清| 峨眉山市| 芜湖市| 扎囊县| 运城市| 镇平县| 渭南市| 石家庄市| 竹溪县| 曲阳县| 饶河县| 电白县| 达州市| 沙坪坝区| 长武县| 拉萨市| 眉山市| 新田县|