使用默认格式格式化和分析日期
import java.text.DateFormat;// from 时 代 J a v a - nowjava.com import java.text.ParseException; import java.util.Date; public class Main { public static void main(String[] argv) throws Exception { // Format Date date = new Date(); String s = DateFormat.getDateInstance(DateFormat.SHORT).format(date); // 2/16/02 s = DateFormat.getDateInstance(DateFormat.MEDIUM).format(date); // Feb 16, 2002 s = DateFormat.getDateInstance(DateFormat.LONG).format(date); // February 16, 2002 s = DateFormat.getDateInstance(DateFormat.FULL).format(date); // Saturday, February 16, 2002 // This is same as MEDIUM/** N o w J a v a . c o m 提供 **/ s = DateFormat.getDateInstance().format(date); // Feb 16, 2002 // This is same as MEDIUM s = DateFormat.getDateInstance(DateFormat.DEFAULT).format(date); // Feb 16, 2002