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


Java CalendarDataUtility.retrieveJavaTimeFieldValueName方法代码示例

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


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

示例1: getText

import sun.util.locale.provider.CalendarDataUtility; //导入方法依赖的package包/类
/**
 * Gets the text for the specified chrono, field, locale and style
 * for the purpose of formatting.
 * <p>
 * The text associated with the value is returned.
 * The null return value should be used if there is no applicable text, or
 * if the text would be a numeric representation of the value.
 *
 * @param chrono  the Chronology to get text for, not null
 * @param field  the field to get text for, not null
 * @param value  the field value to get text for, not null
 * @param style  the style to get text for, not null
 * @param locale  the locale to get text for, not null
 * @return the text for the field value, null if no text found
 */
public String getText(Chronology chrono, TemporalField field, long value,
                                TextStyle style, Locale locale) {
    if (chrono == IsoChronology.INSTANCE
            || !(field instanceof ChronoField)) {
        return getText(field, value, style, locale);
    }

    int fieldIndex;
    int fieldValue;
    if (field == ERA) {
        fieldIndex = Calendar.ERA;
        if (chrono == JapaneseChronology.INSTANCE) {
            if (value == -999) {
                fieldValue = 0;
            } else {
                fieldValue = (int) value + 2;
            }
        } else {
            fieldValue = (int) value;
        }
    } else if (field == MONTH_OF_YEAR) {
        fieldIndex = Calendar.MONTH;
        fieldValue = (int) value - 1;
    } else if (field == DAY_OF_WEEK) {
        fieldIndex = Calendar.DAY_OF_WEEK;
        fieldValue = (int) value + 1;
        if (fieldValue > 7) {
            fieldValue = Calendar.SUNDAY;
        }
    } else if (field == AMPM_OF_DAY) {
        fieldIndex = Calendar.AM_PM;
        fieldValue = (int) value;
    } else {
        return null;
    }
    return CalendarDataUtility.retrieveJavaTimeFieldValueName(
            chrono.getCalendarType(), fieldIndex, fieldValue, style.toCalendarStyle(), locale);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:54,代码来源:DateTimeTextProvider.java

示例2: checkValueRange

import sun.util.locale.provider.CalendarDataUtility; //导入方法依赖的package包/类
private static void checkValueRange(String calType, int field, int value, int style, Locale l, boolean isNonNull) {
    String ret = CalendarDataUtility.retrieveJavaTimeFieldValueName(calType, field, value, style, l);
    System.out.print("retrieveFieldValueName("+calType+", "+field+", "+value+", "+style+", "+l+")");
    if ((ret != null) == isNonNull) {
        System.out.println(" returned "+ret);
    } else {
        throw new RuntimeException("The call returned "+ret);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:Bug8007038.java


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