|
![]() |
名片设计 CorelDRAW Illustrator AuotoCAD Painter 其他软件 Photoshop Fireworks Flash |
|
import java.util.Date;import java.text.DateFormat; /** * 格式化时间类 * DateFormat.FULL = 0 * DateFormat.DEFAULT = 2 * DateFormat.LONG = 1 * DateFormat.MEDIUM = 2 * DateFormat.SHORT = 3 * @author 曲金龙 qujl@neusoft.com * @version 1.0, 2005/04/16 */ public class FormatDate{ public static void main(String []args){ Date d = new Date(); String s; /** Date类的格式: Sat Apr 16 13:17:29 CST 2005 */ System.out.println(d); System.out.println("******************************************"); /** getDateInstance() */ /** 输出格式: 2005-4-16 */ s = DateFormat.getDateInstance().format(d); System.out.println(s); /** 输出格式: 2005-4-16 */ s = DateFormat.getDateInstance(DateFormat.DEFAULT).format(d); System.out.println(s); /** 输出格式: 2005年4月16日 星期六 */ s = DateFormat.getDateInstance(DateFormat.FULL).format(d); System.out.println(s); /** 输出格式: 2005-4-16 */ s = DateFormat.getDateInstance(DateFormat.MEDIUM).format(d); System.out.println(s); /** 输出格式: 05-4-16 */ s = DateFormat.getDateInstance(DateFormat.SHORT).format(d); System.out.println(s); System.out.println("******************************************"); }} 返回类别: 教程 上一教程: Java中非常机制的研究 下一教程: MIDP2.0下处理Alpha通道产生半透明效果 您可以阅读与"使用DateFormat类输出各种格式的时间(上)"相关的教程: · 最简朴的时间格式类 · 格式化输入日期时间控件 JieFormattedDateBox · 小TIP:Java里的时间比较 · JAVA数据库编程中查询结果的表格式输出 · JSP中EMAIL格式的判定 |
![]() ![]() |
快精灵印艺坊 版权所有 |
首页![]() ![]() ![]() ![]() ![]() ![]() ![]() |