黑豆熊——BlogJava

          面對挑戰(zhàn),我告訴自己:面對是勇氣,積極面對是態(tài)度,堅持積極面對是毅力!

          常用鏈接

          統(tǒng)計

          積分與排名

          最新評論

          JAVA格式化時間日期

          import java.util.Date;
          import java.text.DateFormat;


          /**
          * 格式化時間類
          * DateFormat.FULL = 0
          * DateFormat.DEFAULT = 2
          * DateFormat.LONG = 1
          * DateFormat.MEDIUM = 2
          * DateFormat.SHORT = 3
          * @author    Michael
          * @version   1.0, 2007/03/09
          */

          public class Test{
              public static void main(String []args){
                  Date d = new Date();
                  String s;
                   
                  /** Date類的格式: Sat Apr 16 13:17:29 CST 2006 */
                  System.out.println(d);
                   
                  System.out.println("******************************************");  
                 
                  /** getDateInstance() */
                  /** 輸出格式: 2006-4-16 */
                  s = DateFormat.getDateInstance().format(d);
                  System.out.println(s);
                 
                  /** 輸出格式: 2006-4-16 */
                  s = DateFormat.getDateInstance(DateFormat.DEFAULT).format(d);
                  System.out.println(s);
                 
                  /** 輸出格式: 2006年4月16日 星期六 */
                  s = DateFormat.getDateInstance(DateFormat.FULL).format(d);
                  System.out.println(s);
                 
                  /** 輸出格式: 2006-4-16 */
                  s = DateFormat.getDateInstance(DateFormat.MEDIUM).format(d);
                  System.out.println(s);
                 
                  /** 輸出格式: 06-4-16 */
                  s = DateFormat.getDateInstance(DateFormat.SHORT).format(d);
                  System.out.println(s);
                 
                  /** 輸出格式: 2006-01-01 00:00:00 */
                  java.text.DateFormat format1 = new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                  s = format1.format(new Date());
                  System.out.println(s);
                 
                  /** 輸出格式: 2006-01-01 00:00:00 */
                  System.out.println((new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss")).format(new Date()));
                 
                  /** 輸出格式: 20060101000000***/
                  java.text.DateFormat format2 = new java.text.SimpleDateFormat("yyyyMMddhhmmss");
                  s = format2.format(new Date());
                  System.out.println(s);
              }
          }  

          posted on 2008-11-05 10:43 黑豆熊 閱讀(58350) 評論(6)  編輯  收藏

          評論

          # re: JAVA格式化時間日期 2008-12-30 13:22 北京時間

          多謝  回復  更多評論   

          # re: JAVA格式化時間日期[未登錄] 2013-09-04 00:22 過客

          經(jīng)典總要好評  回復  更多評論   

          # re: JAVA格式化時間日期[未登錄] 2013-09-26 16:18 aaaaa

          多謝  回復  更多評論   

          # re: JAVA格式化時間日期 2013-10-25 12:32 mj

          謝了  回復  更多評論   

          # re: JAVA格式化時間日期 2013-11-25 08:36 曉月

          灰常感謝。  回復  更多評論   

          # re: JAVA格式化時間日期 2014-12-19 09:57 11111

          頂  回復  更多評論   


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


          網(wǎng)站導航:
           
          主站蜘蛛池模板: 吴旗县| 聂拉木县| 南开区| 勐海县| 逊克县| 富蕴县| 青川县| 电白县| 井陉县| 平江县| 依兰县| 黔江区| 延川县| 乐东| 定兴县| 岱山县| 阿鲁科尔沁旗| 睢宁县| 泰宁县| 诸暨市| 盐山县| 新巴尔虎右旗| 中牟县| 章丘市| 红桥区| 盐津县| 利津县| 宽城| 韶山市| 吉林市| 什邡市| 乌拉特前旗| 连南| 耒阳市| 鹿泉市| 广宗县| 石门县| 英山县| 西安市| 沙河市| 微博|