黑豆熊——BlogJava

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

          常用鏈接

          統(tǒng)計(jì)

          積分與排名

          最新評(píng)論

          JAVA格式化時(shí)間日期

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


          /**
          * 格式化時(shí)間類(lèi)
          * 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類(lèi)的格式: 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) 評(píng)論(6)  編輯  收藏

          評(píng)論

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

          多謝  回復(fù)  更多評(píng)論   

          # re: JAVA格式化時(shí)間日期[未登錄](méi) 2013-09-04 00:22 過(guò)客

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

          # re: JAVA格式化時(shí)間日期[未登錄](méi) 2013-09-26 16:18 aaaaa

          多謝  回復(fù)  更多評(píng)論   

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

          謝了  回復(fù)  更多評(píng)論   

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

          灰常感謝。  回復(fù)  更多評(píng)論   

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

          頂  回復(fù)  更多評(píng)論   


          只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 兴文县| 新绛县| 阳泉市| 岳阳市| 陆良县| 随州市| 祁门县| 志丹县| 武乡县| 乡宁县| 濮阳市| 大英县| 沭阳县| 濉溪县| 雅安市| 青川县| 石泉县| 敦煌市| 酒泉市| 宽甸| 林芝县| 江安县| 平潭县| 丰镇市| 尼木县| 中山市| 抚顺市| 云阳县| 吉安市| 连南| 桃江县| 霍山县| 桂林市| 分宜县| 昭觉县| 和顺县| 托克托县| 东阳市| 丽江市| 广南县| 麻栗坡县|