望塵軒中一盞茶

          統(tǒng)計

          留言簿

          友情鏈接

          閱讀排行榜

          評論排行榜

          Java格式化日期時間格式


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

           9public 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}
          這里程序的輸出結(jié)果為:2008年10月07日 14時26分27秒
           

          posted on 2008-10-07 14:28 wzhongyu 閱讀(2209) 評論(0)  編輯  收藏 所屬分類: Java學習

          我的便捷門:綜合頻道 數(shù)碼頻道 商城頻道 電器頻道 男人頻道 女人頻道 居家玩具 美容頻道 飾品鞋包 食品頻道 臺灣館頻道
          主站蜘蛛池模板: 西畴县| 三门县| 句容市| 曲靖市| 萨迦县| 桑植县| 峨山| 新沂市| 鄂尔多斯市| 邯郸县| 关岭| 饶河县| 贵阳市| 宜宾县| 久治县| 白银市| 彭水| 澎湖县| 宁陕县| 丹江口市| 陆丰市| 辽阳市| 龙里县| 咸宁市| 马鞍山市| 葵青区| 防城港市| 龙江县| 米易县| 嘉禾县| 呼图壁县| 鹤山市| 海南省| 家居| 古丈县| 师宗县| 特克斯县| 厦门市| 平度市| 沂水县| 青岛市|