格式化和分析区域设置的日期
/*n o w j a v a . c o m 提供*/ import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { void m() throws Exception { Locale locale = Locale.FRENCH; // Format with a custom format DateFormat formatter = new SimpleDateFormat("E, dd MMM yyyy", locale); String s = formatter.format(new Date()); /* 来自 *N o w J a v a . c o m - 时 代 Java*/ System.out.println(s); // Format with a default format s = DateFormat.getDateInstance(DateFormat.MEDIUM, locale) .format(new Date()); System.out.println(s); try { // Parse with a custom format formatter = new SimpleDateFormat("E, dd MMM yyyy", locale); Date date = (Date) formatter.parse("mar., 29 janv. 2002"); System.out.println(date);