当前位置: 首页>>代码示例>>Java>>正文


Java CalendarDataUtility.retrieveFieldValueName方法代码示例

本文整理汇总了Java中sun.util.locale.provider.CalendarDataUtility.retrieveFieldValueName方法的典型用法代码示例。如果您正苦于以下问题:Java CalendarDataUtility.retrieveFieldValueName方法的具体用法?Java CalendarDataUtility.retrieveFieldValueName怎么用?Java CalendarDataUtility.retrieveFieldValueName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sun.util.locale.provider.CalendarDataUtility的用法示例。


在下文中一共展示了CalendarDataUtility.retrieveFieldValueName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDisplayName

import sun.util.locale.provider.CalendarDataUtility; //导入方法依赖的package包/类
@Override
public String getDisplayName(int field, int style, Locale locale) {
    if (!checkDisplayNameParams(field, style, SHORT, NARROW_FORMAT, locale,
                                ERA_MASK|YEAR_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) {
        return null;
    }

    int fieldValue = get(field);

    // "GanNen" is supported only in the LONG style.
    if (field == YEAR
        && (getBaseStyle(style) != LONG || fieldValue != 1 || get(ERA) == 0)) {
        return null;
    }

    String name = CalendarDataUtility.retrieveFieldValueName(getCalendarType(), field,
                                                             fieldValue, style, locale);
    // If the ERA value is null, then
    // try to get its name or abbreviation from the Era instance.
    if (name == null && field == ERA && fieldValue < eras.length) {
        Era era = eras[fieldValue];
        name = (style == SHORT) ? era.getAbbreviation() : era.getName();
    }
    return name;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:JapaneseImperialCalendar.java

示例2: getDisplayName

import sun.util.locale.provider.CalendarDataUtility; //导入方法依赖的package包/类
@Override
public String getDisplayName(int field, int style, Locale locale) {
    if (field != ERA) {
        return super.getDisplayName(field, style, locale);
    }

    return CalendarDataUtility.retrieveFieldValueName("buddhist", field, get(field), style, locale);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:BuddhistCalendar.java

示例3: getDisplayName

import sun.util.locale.provider.CalendarDataUtility; //导入方法依赖的package包/类
/**
 * Returns the string representation of the calendar
 * <code>field</code> value in the given <code>style</code> and
 * <code>locale</code>.  If no string representation is
 * applicable, <code>null</code> is returned. This method calls
 * {@link Calendar#get(int) get(field)} to get the calendar
 * <code>field</code> value if the string representation is
 * applicable to the given calendar <code>field</code>.
 *
 * <p>For example, if this <code>Calendar</code> is a
 * <code>GregorianCalendar</code> and its date is 2005-01-01, then
 * the string representation of the {@link #MONTH} field would be
 * "January" in the long style in an English locale or "Jan" in
 * the short style. However, no string representation would be
 * available for the {@link #DAY_OF_MONTH} field, and this method
 * would return <code>null</code>.
 *
 * <p>The default implementation supports the calendar fields for
 * which a {@link DateFormatSymbols} has names in the given
 * <code>locale</code>.
 *
 * @param field
 *        the calendar field for which the string representation
 *        is returned
 * @param style
 *        the style applied to the string representation; one of {@link
 *        #SHORT_FORMAT} ({@link #SHORT}), {@link #SHORT_STANDALONE},
 *        {@link #LONG_FORMAT} ({@link #LONG}), {@link #LONG_STANDALONE},
 *        {@link #NARROW_FORMAT}, or {@link #NARROW_STANDALONE}.
 * @param locale
 *        the locale for the string representation
 *        (any calendar types specified by {@code locale} are ignored)
 * @return the string representation of the given
 *        {@code field} in the given {@code style}, or
 *        {@code null} if no string representation is
 *        applicable.
 * @exception IllegalArgumentException
 *        if {@code field} or {@code style} is invalid,
 *        or if this {@code Calendar} is non-lenient and any
 *        of the calendar fields have invalid values
 * @exception NullPointerException
 *        if {@code locale} is null
 * @since 1.6
 */
public String getDisplayName(int field, int style, Locale locale) {
    if (!checkDisplayNameParams(field, style, SHORT, NARROW_FORMAT, locale,
                        ERA_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) {
        return null;
    }

    // the standalone and narrow styles are supported only through CalendarDataProviders.
    if (isStandaloneStyle(style) || isNarrowStyle(style)) {
        return CalendarDataUtility.retrieveFieldValueName(getCalendarType(),
                                                          field, get(field),
                                                          style, locale);
    }

    DateFormatSymbols symbols = DateFormatSymbols.getInstance(locale);
    String[] strings = getFieldStrings(field, style, symbols);
    if (strings != null) {
        int fieldValue = get(field);
        if (fieldValue < strings.length) {
            return strings[fieldValue];
        }
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:68,代码来源:Calendar.java


注:本文中的sun.util.locale.provider.CalendarDataUtility.retrieveFieldValueName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。