这是一个快速测试程序:
public static void main( String[] args )
{
Date date = Calendar.getInstance().getTime();
System.out.println("Months:");
printDate( "MMMM", "en", date );
printDate( "MMMM", "es", date );
printDate( "MMMM", "fr", date );
printDate( "MMMM", "de", date );
System.out.println("Days:");
printDate( "EEEE", "en", date );
printDate( "EEEE", "es", date );
printDate( "EEEE", "fr", date );
printDate( "EEEE", "de", date );
}
public static void printDate( String format, String locale, Date date )
{
System.out.println( locale + ": " + (new SimpleDateFormat( format, new Locale( locale ) )).format( date ) );
}
输出是:
Months:
en: September
es: septiembre
fr: septembre
de: September
Days:
en: Monday
es: lunes
fr: lundi
de: Montag
如何控制名称的大小写。出于某种原因,西班牙语和法语似乎总是返回以小写字母开头的名称。