I get an integer and I need to convert to a month names in various locales:
Example for locale en-us:
1 -> January
2 -> February
Example for locale es-mx:
1 -> Enero
2 -> Febrero
DateTime dt = DateTime. Now; Console. WriteLine( dt. ToString( "MMMM" ) );
import java.text.DateFormatSymbols; public String getMonth(int month) { return new DateFormatSymbols().getMonths()[month-1]; }
You need to use LLLL for stand-alone month names. this is documented in the SimpleDateFormat
documentation, such as:
SimpleDateFormat dateFormat = new SimpleDateFormat( "LLLL", Locale.getDefault() ); dateFormat.format( date );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With