tl;dr
Month.OCTOBER.getDisplayName (
TextStyle.FULL_STANDALONE ,
new Locale ( "cs", "CZ" )
)
říjen
Thanks to the Answer by MikeX for showing this is a “standalone” language issue. Unlike English, some languages such as Czech alter the spelling of the month depending on the context of its usage.
Using java.time
The modern approach uses the java.time classes. The Question and other Answers are outdated, using the troublesome old date-time classes (Calendar
, SimpleDateFormat
, DateFormat
, etc.) that are now legacy, supplanted entirely by the java.time classes. See below for back-port to Android.
The Month
enum provides a method for localizing the name of the month: Month::getDisplayName
. Pass a TextStyle
indicating full-narrow-short and whether you want the standalone or combo type.
When can loop through these to see all the possible results.
Locale locale = new Locale ( "cs", "CZ" );
for ( Month month : EnumSet.allOf ( Month.class ) ) {
System.out.println ( "\nMonth: " + month );
for ( TextStyle textStyle : EnumSet.allOf ( TextStyle.class ) ) {
String output = month.getDisplayName ( textStyle, locale ) + " | " + textStyle;
System.out.println ( output );
}
}
Month: JANUARY
ledna | FULL
leden | FULL_STANDALONE
Led | SHORT
I | SHORT_STANDALONE
l | NARROW
l | NARROW_STANDALONE
Month: FEBRUARY
února | FULL
únor | FULL_STANDALONE
Úno | SHORT
II | SHORT_STANDALONE
ú | NARROW
ú | NARROW_STANDALONE
Month: MARCH
března | FULL
březen | FULL_STANDALONE
Bře | SHORT
III | SHORT_STANDALONE
b | NARROW
b | NARROW_STANDALONE
Month: APRIL
dubna | FULL
duben | FULL_STANDALONE
Dub | SHORT
IV | SHORT_STANDALONE
d | NARROW
d | NARROW_STANDALONE
Month: MAY
května | FULL
květen | FULL_STANDALONE
Kvě | SHORT
V | SHORT_STANDALONE
k | NARROW
k | NARROW_STANDALONE
Month: JUNE
června | FULL
červen | FULL_STANDALONE
Čer | SHORT
VI | SHORT_STANDALONE
č | NARROW
č | NARROW_STANDALONE
Month: JULY
července | FULL
červenec | FULL_STANDALONE
Čvc | SHORT
VII | SHORT_STANDALONE
č | NARROW
č | NARROW_STANDALONE
Month: AUGUST
srpna | FULL
srpen | FULL_STANDALONE
Srp | SHORT
VIII | SHORT_STANDALONE
s | NARROW
s | NARROW_STANDALONE
Month: SEPTEMBER
září | FULL
září | FULL_STANDALONE
Zář | SHORT
IX | SHORT_STANDALONE
z | NARROW
z | NARROW_STANDALONE
Month: OCTOBER
října | FULL
říjen | FULL_STANDALONE
Říj | SHORT
X | SHORT_STANDALONE
ř | NARROW
ř | NARROW_STANDALONE
Month: NOVEMBER
listopadu | FULL
listopad | FULL_STANDALONE
Lis | SHORT
XI | SHORT_STANDALONE
l | NARROW
l | NARROW_STANDALONE
Month: DECEMBER
prosince | FULL
prosinec | FULL_STANDALONE
Pro | SHORT
XII | SHORT_STANDALONE
p | NARROW
p | NARROW_STANDALONE
About java.time
The java.time framework is built into Java 8 and later. These classes supplant the troublesome old legacy date-time classes such as java.util.Date
, Calendar
, & SimpleDateFormat
.
The Joda-Time project, now in maintenance mode, advises migration to the java.time classes.
To learn more, see the Oracle Tutorial. And search Stack Overflow for many examples and explanations. Specification is JSR 310.
Where to obtain the java.time classes?