views:

506

answers:

3

Here is a quick test program:

    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 ) );
}

The output is:

Months: en: September es: septiembre fr: septembre de: September Days: en: Monday es: lunes fr: lundi de: Montag

How can I control the capitalization of the names. For some reason the Spanish and French always seem to return names that start with a lowercase letter.

+1  A: 

You may not want to change the capitalization -- different cultures capitalize different words (for example, in German you capitalize every noun, not just proper nouns).

Chris Shaffer
+2  A: 

Not all languages share english capitalization rules. I guess you'd need to alter the data used by the API, but your non-english clients might not appreciate it...

about.com on french capitalization

Brabster
I think you are right. Another link with more details on which languages capitalize and which don't. http://meta.wikimedia.org/wiki/Capitalization#Capitalization_of_month_names
+1  A: 

Capitalisation rules are different for different languages. In French, month names should not be capitalised.

Dan Dyer