tl;dr
Both syyskuu
and syyskuuta
are correct spellings of September
in Finnish. The first is for standalone use, the second for use in context.
The java.time.Month
enum can provide either form of spelling.
java.time
I tried this same kind of code using the modern java.time classes rather than the old outmoded java.util.Date
and java.text.SimpleDateFormat
classes.
The java.time framework built into Java 8 and later. See Oracle Tutorial. Much of the java.time functionality is back-ported to Java 6 & 7 in ThreeTen-Backport and further adapted to Android in ThreeTenABP.
Formatted String of date value
For this example we instantiate a LocalDate
for September 25, 2012 per the Question.
LocalDate ld = LocalDate.of ( 2012 , Month.SEPTEMBER , 25 ); // 2012-09-25
We get a DateTimeFormatter
to automatically localize when generating a String. Calling ofLocalizedDate
means our String will represent only the date portion of the date-time value. The FormatStyle
controls the length of the String (full, long, medium, short).
DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDate ( FormatStyle.LONG );
Next we replace the assignment of our JVM’s current default Locale
with the Finland & Finnish locale. This Locale
object determines two things: (a) the human language used to translate pieces such as name of day or name of month, and (b) the cultural norms for abbreviating, ordering elements such as month or date first, use of commas versus periods, and so on.
Locale locale = new Locale ( "fi" , "FI" );
formatter = formatter.withLocale ( locale );
Use that formatter to actually generate a String
to represent our LocalDate
value.
String output = ld.format ( formatter ); // 25. syyskuuta 2012
Dump to console.
System.out.println ( "ld: " + ld + " with locale: " + locale + " | output: " + output );
- syyskuuta 2012
As shown in the accepted Answer, java.time agrees that syyskuuta
is the name of the month for September.
Month name for display
The java.time classes include the Month
enum. This handy class has a feature for generating a String with the name of the month localized to a Locale
.
This localization is a similar to idea to the localization we saw in code above. But what is different is the use of a different enum to control the length of the text. Here the TextStyle
enum (rather than FormatStyle
) offers full, narrow, and short… but also “standalone” versions of those three lengths. In some languages there is a difference in the word used when the text is used alone, as opposed to in a complete date. Just for fun, let's try that with Finnish.
Locale locale = new Locale ( "fi" , "FI" );
EnumSet<TextStyle> styles = EnumSet.allOf ( TextStyle.class );
for ( TextStyle style : styles ) {
System.out.println ( style + " | " + Month.SEPTEMBER.getDisplayName ( style , locale ) );
}
Mystery solved: Standalone month name
Sure enough, the output below explains the mystery. In Finnish:
- When using the month name alone, drop the
ta
for syyskuu
.
- When used within the context of a specific date-time value include the
ta
for syyskuuta
.
FULL | syyskuuta
FULL_STANDALONE | syyskuu
SHORT | syyskuuta
SHORT_STANDALONE | syys
NARROW | S
NARROW_STANDALONE | S
If you cannot control the improperly formatted inputs to your app, you could search-and-replace any standalone value with its proper version. Or perhaps you could use DateTimeFormatterBuilder
to expect the standalone version (I do not know if this is possible, just a thought).