Don't save short eras if they are the same as the long eras

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1390811 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley 2012-09-27 02:18:18 +00:00
parent 65a6458eaa
commit f899c178b7
1 changed files with 6 additions and 1 deletions

View File

@ -381,9 +381,14 @@ KeyValue[] getDisplayNames(int field) {
// see: https://issues.apache.org/jira/browse/TRINIDAD-2126
Calendar c = Calendar.getInstance(locale);
// N.B. Some calendars have different short and long symbols, e.g. ja_JP_JP
// TODO Seems to be only that locale; if that is guaranteed, could skip some work here
String[] shortEras = toArray(c.getDisplayNames(Calendar.ERA, Calendar.SHORT, locale));
String[] longEras = toArray(c.getDisplayNames(Calendar.ERA, Calendar.LONG, locale));
fieldKeyValues= createKeyValues(longEras, shortEras);
if (Arrays.equals(shortEras, longEras)) {
fieldKeyValues = createKeyValues(longEras, null); // save memory
} else {
fieldKeyValues = createKeyValues(longEras, shortEras);
}
break;
case Calendar.DAY_OF_WEEK:
fieldKeyValues= createKeyValues(symbols.getWeekdays(), symbols.getShortWeekdays());