6

Referring to the SimpleDateFormat docs, the pattern character for representing years is y, so we have representations like yy and yyyy (13, 2013 respectively). That's fine.

When I output the DEFAULT / SHORT / MEDIUM / LONG / FULL patterns for most locales, I get something along these lines:

(EG: New Zealand)

Default: d/MM/yyyy
Short: d/MM/yy
Medium: d/MM/yyyy
Long: d MMMM yyyy
Full: EEEE, d MMMM yyyy

However looking at some locales, eg France, I get this:

Default: j MMM aaaa
Short: jj/MM/aa
Medium: j MMM aaaa
Long: j MMMM aaaa
Full: EEEE j MMMM aaaa

Obviously here aaaa is a representation of the year, but what's the distinction in intent between yyyy and aaaa? IE: why do they use aaaa instead of just yyyy.

Initially I thought it might be something along the lines of French for "[y]ear" is "[a]nnée" (and "[d]ay" is "[j]our", but I see it's also aaaa for Hungarian (and many other locales), and Hungarian for "year" is "év" (day "nap"), so I think the "a" / "année" correlation I'm making is coincidence.

So what is the difference one is supposed to infer here?

I googled about, but drew a blank. Also it might be as obvious as an obvious thing to a Java dev, but I'm just a CFML dev who simply bolts Java into my CFML occasionally when Java does something more expediently than I can do it in native CFML. So sorry if it's a dumb question.

Adam Cameron
  • 29,677
  • 4
  • 37
  • 78

1 Answers1

4

If you look at java.text.DateFormatSymbols you'll find the following field:

/**
 * Localized date-time pattern characters. For example, a locale may
 * wish to use 'u' rather than 'y' to represent years in its date format
 * pattern strings.
 * This string must be exactly 18 characters long, with the index of
 * the characters described by <code>DateFormat.ERA_FIELD</code>,
 * <code>DateFormat.YEAR_FIELD</code>, etc.  Thus, if the string were
 * "Xz...", then localized patterns would use 'X' for era and 'z' for year.
 * @serial
 */
String  localPatternChars = null;

This is a string containing a character for each format element in a predefined order (E.g., character 0 is the Era format character, character 1 is the Year format character, etc).

This field is loaded from the sun.text.resources.FormatData resource bundle (per locale, of course), from the DateTimePatternChars key.

If you examine the sun.text.resources.FormatData_fr resource, you'll find the key-value pair { "DateTimePatternChars", "GaMjkHmsSEDFwWxhKzZ" }.

To make a long story short - the "a" format character in France locale has the exact same effect as the "y" format character in US locale, it's just called differently.

Mureinik
  • 297,002
  • 52
  • 306
  • 350