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 : 年月日 星期日 |