< prev index next >

src/java.base/share/classes/java/util/Calendar.java

Print this page
rev 55815 : [mq]: 8228465


2188      *        the locale for the display names
2189      * @return a {@code Map} containing all display names in
2190      *        {@code style} and {@code locale} and their
2191      *        field values, or {@code null} if no display names
2192      *        are defined for {@code field}
2193      * @exception IllegalArgumentException
2194      *        if {@code field} or {@code style} is invalid,
2195      *        or if this {@code Calendar} is non-lenient and any
2196      *        of the calendar fields have invalid values
2197      * @exception NullPointerException
2198      *        if {@code locale} is null
2199      * @since 1.6
2200      */
2201     public Map<String, Integer> getDisplayNames(int field, int style, Locale locale) {
2202         if (!checkDisplayNameParams(field, style, ALL_STYLES, NARROW_FORMAT, locale,
2203                                     ERA_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) {
2204             return null;
2205         }
2206 
2207         String calendarType = getCalendarType();
2208         if (style == ALL_STYLES || isStandaloneStyle(style) || isNarrowFormatStyle(style)) {

2209             Map<String, Integer> map;
2210             map = CalendarDataUtility.retrieveFieldValueNames(calendarType, field, style, locale);
2211 
2212             // Perform fallback here to follow the CLDR rules
2213             if (map == null) {
2214                 if (isNarrowFormatStyle(style)) {
2215                     map = CalendarDataUtility.retrieveFieldValueNames(calendarType, field,
2216                                                                       toStandaloneStyle(style), locale);
2217                 } else if (style != ALL_STYLES) {
2218                     map = CalendarDataUtility.retrieveFieldValueNames(calendarType, field,
2219                                                                       getBaseStyle(style), locale);
2220                 }
2221             }
2222             return map;
2223         }
2224 
2225         // SHORT or LONG
2226         return getDisplayNamesImpl(field, style, locale);
2227     }
2228 




2188      *        the locale for the display names
2189      * @return a {@code Map} containing all display names in
2190      *        {@code style} and {@code locale} and their
2191      *        field values, or {@code null} if no display names
2192      *        are defined for {@code field}
2193      * @exception IllegalArgumentException
2194      *        if {@code field} or {@code style} is invalid,
2195      *        or if this {@code Calendar} is non-lenient and any
2196      *        of the calendar fields have invalid values
2197      * @exception NullPointerException
2198      *        if {@code locale} is null
2199      * @since 1.6
2200      */
2201     public Map<String, Integer> getDisplayNames(int field, int style, Locale locale) {
2202         if (!checkDisplayNameParams(field, style, ALL_STYLES, NARROW_FORMAT, locale,
2203                                     ERA_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) {
2204             return null;
2205         }
2206 
2207         String calendarType = getCalendarType();
2208         if (style == ALL_STYLES || isStandaloneStyle(style) || isNarrowFormatStyle(style) ||
2209             field == ERA && (style & SHORT) == SHORT) {
2210             Map<String, Integer> map;
2211             map = CalendarDataUtility.retrieveFieldValueNames(calendarType, field, style, locale);
2212 
2213             // Perform fallback here to follow the CLDR rules
2214             if (map == null) {
2215                 if (isNarrowFormatStyle(style)) {
2216                     map = CalendarDataUtility.retrieveFieldValueNames(calendarType, field,
2217                                                                       toStandaloneStyle(style), locale);
2218                 } else if (style != ALL_STYLES) {
2219                     map = CalendarDataUtility.retrieveFieldValueNames(calendarType, field,
2220                                                                       getBaseStyle(style), locale);
2221                 }
2222             }
2223             return map;
2224         }
2225 
2226         // SHORT or LONG
2227         return getDisplayNamesImpl(field, style, locale);
2228     }
2229 


< prev index next >