隨筆 - 147  文章 - 71  trackbacks - 0
          <2009年6月>
          31123456
          78910111213
          14151617181920
          21222324252627
          2829301234
          567891011

          常用鏈接

          留言簿(1)

          隨筆分類(146)

          隨筆檔案(147)

          文章分類(28)

          文章檔案(28)

          喜歡的Blog

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

           今天寫了一個格式化日期時間格式的程序,在這里記錄一下,同時也方便需要的人使用。程序代碼如下:
           1 import java.text.SimpleDateFormat;
           2 import java.util.Date;
           3 
           4  /**
           5  * 
           6  * 格式化日期
           7  *
           8  */

           9 public class FormatDate
          10{
          11    public static String formatDate(Date date){
          12        SimpleDateFormat sdf = new SimpleDateFormat("yyyy 年 MM 月 dd 日");
          13        return sdf.format(date);
          14    }

          15    
          16    public static String formatTime(Date date){
          17        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH時mm分ss秒");
          18        return sdf.format(date);
          19    }

          20    
          21    public static void main(String[] args){
          22        System.out.println(formatTime(new Date()));
          23    }

          24}

           這里程序的輸出結果為:2008年10月07日 14時26分27秒
          posted on 2009-06-23 21:08 飛翔天使 閱讀(371) 評論(0)  編輯  收藏 所屬分類: java
          主站蜘蛛池模板: 察哈| 阜康市| 多伦县| 佳木斯市| 永和县| 达州市| 无锡市| 新泰市| 玛曲县| 永登县| 行唐县| 邢台县| 大安市| 彰武县| 介休市| 宕昌县| 巴南区| 卢湾区| 司法| 华坪县| 洛宁县| 招远市| 大化| 万山特区| 阿合奇县| 蒙山县| 育儿| 阜阳市| 云梦县| 柏乡县| 襄城县| 酒泉市| 循化| 瓦房店市| 团风县| 汉川市| 宿州市| 达拉特旗| 白城市| 镇沅| 剑河县|