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)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 郴州市| 古浪县| 闸北区| 健康| 青海省| 东乡| 湖州市| 当阳市| 辛集市| 英山县| 南澳县| 盐亭县| 刚察县| 吉木萨尔县| 无为县| 北宁市| 金门县| 北票市| 东光县| 元朗区| 剑河县| 儋州市| 民县| 同江市| 和平区| 察雅县| 瑞安市| 时尚| 贵州省| 吉水县| 琼结县| 汾西县| 建水县| 泰兴市| 金塔县| 黄大仙区| 康平县| 沅江市| 岳阳县| 柳江县| 习水县|