熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> JSP教程 >> 正文

日期的顯示格式化

2013-11-15 11:43:37  來源: JSP教程 

  import javautil*;
  import javatext*;
  public class FormatDate {
   public static void main(String[] args) {
    Date now = new Date();
  
    DateFormat defaultFormat = DateFormatgetDateInstance();
    DateFormat shortFormat = DateFormatgetDateInstance(DateFormatSHORT);
    DateFormat mediumFormat = DateFormatgetDateInstance(DateFormatMEDIUM);
    DateFormat longFormat = DateFormatgetDateInstance(DateFormatLONG);
    DateFormat fullFormat = DateFormatgetDateInstance(DateFormatFULL);
    String defaultDate = defaultFormatformat(now);
    String shortDate = shortFormatformat(now);
    String mediumDate = mediumFormatformat(now);
    String longDate = longFormatformat(now);
    String fullDate = fullFormatformat(now);
  
    Systemoutprintln((Default) Today : + defaultDate);
    Systemoutprintln((SHORT) Today : + shortDate);
    Systemoutprintln((MEDIUM) Today : + mediumDate);
    Systemoutprintln((LONG) Today : + longDate);
    Systemoutprintln((FULL) Today : + fullDate);
   }
  }
  
  運行結果為:
  D:\javamail>java FormatDate
  (Default) Today :
  (SHORT) Today :
  (MEDIUM) Today :
  (LONG) Today :
  (FULL) Today : 日 星期日
  

From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19499.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.