70 // try the default ones instead.
71 if (strings == null && key.indexOf("standalone.") != -1) {
72 key = key.replaceFirst("standalone.", "");
73 strings = javatime ? lr.getJavaTimeNames(key) : lr.getCalendarNames(key);
74 }
75
76 if (strings != null && strings.length > 0) {
77 if (field == DAY_OF_WEEK || field == YEAR) {
78 --value;
79 }
80 if (value < 0 || value > strings.length) {
81 return null;
82 } else if (value == strings.length) {
83 if (field == ERA && "japanese".equals(calendarType)) {
84 // get the supplemental era, if any, specified through
85 // the property "jdk.calendar.japanese.supplemental.era"
86 // which is always the last element.
87 Era[] jeras = CalendarSystem.forName("japanese").getEras();
88 if (jeras.length == value) {
89 Era supEra = jeras[value - 1]; // 0-based index
90 return style == LONG ?
91 supEra.getName() :
92 supEra.getAbbreviation();
93 }
94 }
95 return null;
96 }
97 name = strings[value];
98 // If name is empty in standalone, try its `format' style.
99 if (name.length() == 0
100 && (style == SHORT_STANDALONE || style == LONG_STANDALONE
101 || style == NARROW_STANDALONE)) {
102 name = getDisplayName(calendarType, field, value,
103 getBaseStyle(style),
104 locale);
105 }
106 }
107 }
108 return name;
109 }
110
111 private static int[] REST_OF_STYLES = {
112 SHORT_STANDALONE, LONG_FORMAT, LONG_STANDALONE,
113 NARROW_FORMAT, NARROW_STANDALONE
114 };
|
70 // try the default ones instead.
71 if (strings == null && key.indexOf("standalone.") != -1) {
72 key = key.replaceFirst("standalone.", "");
73 strings = javatime ? lr.getJavaTimeNames(key) : lr.getCalendarNames(key);
74 }
75
76 if (strings != null && strings.length > 0) {
77 if (field == DAY_OF_WEEK || field == YEAR) {
78 --value;
79 }
80 if (value < 0 || value > strings.length) {
81 return null;
82 } else if (value == strings.length) {
83 if (field == ERA && "japanese".equals(calendarType)) {
84 // get the supplemental era, if any, specified through
85 // the property "jdk.calendar.japanese.supplemental.era"
86 // which is always the last element.
87 Era[] jeras = CalendarSystem.forName("japanese").getEras();
88 if (jeras.length == value) {
89 Era supEra = jeras[value - 1]; // 0-based index
90 if (javatime) {
91 return getBaseStyle(style) == NARROW_FORMAT ?
92 supEra.getAbbreviation() :
93 supEra.getName();
94 } else {
95 return (style & LONG) != 0 ?
96 supEra.getName() :
97 supEra.getAbbreviation();
98 }
99 }
100 }
101 return null;
102 }
103 name = strings[value];
104 // If name is empty in standalone, try its `format' style.
105 if (name.length() == 0
106 && (style == SHORT_STANDALONE || style == LONG_STANDALONE
107 || style == NARROW_STANDALONE)) {
108 name = getDisplayName(calendarType, field, value,
109 getBaseStyle(style),
110 locale);
111 }
112 }
113 }
114 return name;
115 }
116
117 private static int[] REST_OF_STYLES = {
118 SHORT_STANDALONE, LONG_FORMAT, LONG_STANDALONE,
119 NARROW_FORMAT, NARROW_STANDALONE
120 };
|