tl;dr
Month.of( yourMonthNumber ).getDisplayName( TextStyle.SHORT_STANDALONE , Locale.CANADA_FRENCH )
java.time.Month
Much easier to do now in the java.time classes that supplant these troublesome old legacy date-time classes.
The Month
enum defines a dozen objects, one for each month.
The months are numbered 1-12 for January-December.
Month month = Month.of( 2 ); // 2 → February.
Ask the object to generate a String of the name of the month, automatically localized. Adjust the TextStyle
to specify how long or abbreviated you want the name. Specify a Locale
to say which human language should be used in translation and what cultural norms should decide issues such as abbreviation, punctuation, and capitalization.
String output = Month.FEBRUARY.getDisplayName( TextStyle.SHORT_STANDALONE , Locale.CANADA_FRENCH );
About java.time
The java.time framework is built into Java 8 and later. These classes supplant the troublesome old date-time classes such as java.util.Date
, .Calendar
, & java.text.SimpleDateFormat
.
The Joda-Time project, now in maintenance mode, advises migration to java.time.
To learn more, see the Oracle Tutorial. And search Stack Overflow for many examples and explanations.
Much of the java.time functionality is back-ported to Java 6 & 7 in ThreeTen-Backport and further adapted to Android in ThreeTenABP (see How to use…).
The ThreeTen-Extra project extends java.time with additional classes. This project is a proving ground for possible future additions to java.time. You may find some useful classes here such as Interval
, YearWeek
, YearQuarter
, and more.