Java – how is “AAAA” different from “yyyy” in the context of year values?
Referring to simpledateformat docs, the mode character representing the year is y, so we have YY and yyyy (2013 respectively) No problem.
When I output the default / short / medium / long / full mode for most locales, I get the following points:
(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 places, such as 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, AAAA is the representative of the year, but what is the intended difference between yyyy and AAAA? Ie: why do they use AAAA instead of just yyyy
At first I thought it might be part of French, because "[y] ear" is "[a] NN é e" (and "[D] ay" is "[J] ours", but I saw that it is also the AAAA of Hungarian (and many other language environments), and the "year" in Hungarian is "é V" (day "nap"), so I think the correlation between "a" / "Ann é e" I made is a coincidence
So what are the differences that should be inferred here?
I used Google to search, but I drew a blank It may be obvious to Java developers, but I'm just a CFML developer. When Java is more convenient than I do in native CFML, he occasionally fixes Java into my CFML If this is a stupid question, I'm sorry
Solution
If you look at Java text. Dateformatsymbols, you will find the following fields:
/** * 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 that contains the characters of each format element in a predefined order (for example, character 0 is era format character, character 1 is year format character, and so on)
This field is from the datetimepatternchars key from sun text. resources. The formatdata resource package (of course, for each locale) is loaded
If you check sun text. resources. FormatData_ Fr resource, you will find the key value pair {"datetimepatternchars", "gamjkhmssedfwwxhkzz"}
To make a long story short - the "a" format character in the French locale has exactly the same effect as the "Y" format character in the American locale, and it is called in a different way