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


Java TemporalField.rangeRefinedBy方法代码示例

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


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

示例1: range

import java.time.temporal.TemporalField; //导入方法依赖的package包/类
@Override
public ValueRange range(TemporalField field) {
    if (field instanceof ChronoField) {
        if (isSupported(field)) {
            ChronoField f = (ChronoField) field;
            switch (f) {
                case DAY_OF_MONTH: return ValueRange.of(1, lengthOfMonth());
                case DAY_OF_YEAR: return ValueRange.of(1, lengthOfYear());
                case ALIGNED_WEEK_OF_MONTH: return ValueRange.of(1, 5);  // TODO
                // TODO does the limited range of valid years cause years to
                // start/end part way through? that would affect range
            }
            return getChronology().range(f);
        }
        throw new UnsupportedTemporalTypeException("Unsupported field: " + field);
    }
    return field.rangeRefinedBy(this);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:HijrahDate.java

示例2: range

import java.time.temporal.TemporalField; //导入方法依赖的package包/类
@Override
public ValueRange range(TemporalField field) {
    if (field instanceof ChronoField) {
        if (isSupported(field)) {
            ChronoField f = (ChronoField) field;
            switch (f) {
                case DAY_OF_MONTH: return ValueRange.of(1, lengthOfMonth());
                case DAY_OF_YEAR: return ValueRange.of(1, lengthOfYear());
                case ALIGNED_WEEK_OF_MONTH: return ValueRange.of(1, month == 13 ? 1 : 5);
                case YEAR:
                case YEAR_OF_ERA: return (prolepticYear <= 0 ?
                        ValueRange.of(1, Year.MAX_VALUE + 1) : ValueRange.of(1, Year.MAX_VALUE));  // TODO
            }
            return getChronology().range(f);
        }
        throw new UnsupportedTemporalTypeException("Unsupported field: " + field);
    }
    return field.rangeRefinedBy(this);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:CopticDate.java

示例3: range

import java.time.temporal.TemporalField; //导入方法依赖的package包/类
@Override
public ValueRange range(TemporalField field) {
    if (field instanceof ChronoField) {
        if (isSupported(field)) {
            ChronoField f = (ChronoField) field;
            switch (f) {
                case DAY_OF_MONTH: return ValueRange.of(1, lengthOfMonth());
                case DAY_OF_YEAR: return ValueRange.of(1, lengthOfYear());
                case YEAR_OF_ERA: {
                    Calendar jcal = Calendar.getInstance(JapaneseChronology.LOCALE);
                    jcal.set(Calendar.ERA, era.getValue() + JapaneseEra.ERA_OFFSET);
                    jcal.set(yearOfEra, isoDate.getMonthValue() - 1, isoDate.getDayOfMonth());
                    return ValueRange.of(1, jcal.getActualMaximum(Calendar.YEAR));
                }
            }
            return getChronology().range(f);
        }
        throw new UnsupportedTemporalTypeException("Unsupported field: " + field);
    }
    return field.rangeRefinedBy(this);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:JapaneseDate.java

示例4: range

import java.time.temporal.TemporalField; //导入方法依赖的package包/类
@Override
public ValueRange range(TemporalField field) {
    if (field instanceof ChronoField) {
        ChronoField f = (ChronoField) field;
        return (f.isTimeBased() ? time.range(field) : date.range(field));
    }
    return field.rangeRefinedBy(this);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:ChronoLocalDateTimeImpl.java

示例5: range

import java.time.temporal.TemporalField; //导入方法依赖的package包/类
@Override
default ValueRange range(TemporalField field) {
    if (field instanceof ChronoField) {
        if (field == INSTANT_SECONDS || field == OFFSET_SECONDS) {
            return field.range();
        }
        return toLocalDateTime().range(field);
    }
    return field.rangeRefinedBy(this);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:ChronoZonedDateTime.java

示例6: range

import java.time.temporal.TemporalField; //导入方法依赖的package包/类
@Override
public ValueRange range(TemporalField field) {
    if (field instanceof ChronoField) {
        if (isSupported(field)) {
            return field.range();
        }
        throw new UnsupportedTemporalTypeException("Unsupported field: " + field);
    }
    return field.rangeRefinedBy(this);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:MockFieldValue.java

示例7: range

import java.time.temporal.TemporalField; //导入方法依赖的package包/类
/**
 * Gets the range of valid values for the specified field.
 * <p>
 * The range object expresses the minimum and maximum valid values for a field.
 * This date is used to enhance the accuracy of the returned range.
 * If it is not possible to return the range, because the field is not supported
 * or for some other reason, an exception is thrown.
 * <p>
 * If the field is a {@link ChronoField} then the query is implemented here.
 * The {@link #isSupported(TemporalField) supported fields} will return
 * appropriate range instances.
 * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}.
 * <p>
 * If the field is not a {@code ChronoField}, then the result of this method
 * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)}
 * passing {@code this} as the argument.
 * Whether the range can be obtained is determined by the field.
 *
 * @param field  the field to query the range for, not null
 * @return the range of valid values for the field, not null
 * @throws DateTimeException if the range for the field cannot be obtained
 * @throws UnsupportedTemporalTypeException if the field is not supported
 */
@Override
public ValueRange range(TemporalField field) {
    if (field instanceof ChronoField) {
        ChronoField f = (ChronoField) field;
        if (f.isDateBased()) {
            switch (f) {
                case DAY_OF_MONTH: return ValueRange.of(1, lengthOfMonth());
                case DAY_OF_YEAR: return ValueRange.of(1, lengthOfYear());
                case ALIGNED_WEEK_OF_MONTH: return ValueRange.of(1, getMonth() == Month.FEBRUARY && isLeapYear() == false ? 4 : 5);
                case YEAR_OF_ERA:
                    return (getYear() <= 0 ? ValueRange.of(1, Year.MAX_VALUE + 1) : ValueRange.of(1, Year.MAX_VALUE));
            }
            return field.range();
        }
        throw new UnsupportedTemporalTypeException("Unsupported field: " + field);
    }
    return field.rangeRefinedBy(this);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:42,代码来源:LocalDate.java

示例8: range

import java.time.temporal.TemporalField; //导入方法依赖的package包/类
/**
 * Gets the range of valid values for the specified field.
 * <p>
 * The range object expresses the minimum and maximum valid values for a field.
 * This date-time is used to enhance the accuracy of the returned range.
 * If it is not possible to return the range, because the field is not supported
 * or for some other reason, an exception is thrown.
 * <p>
 * If the field is a {@link ChronoField} then the query is implemented here.
 * The {@link #isSupported(TemporalField) supported fields} will return
 * appropriate range instances.
 * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}.
 * <p>
 * If the field is not a {@code ChronoField}, then the result of this method
 * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)}
 * passing {@code this} as the argument.
 * Whether the range can be obtained is determined by the field.
 *
 * @param field  the field to query the range for, not null
 * @return the range of valid values for the field, not null
 * @throws DateTimeException if the range for the field cannot be obtained
 * @throws UnsupportedTemporalTypeException if the field is not supported
 */
@Override
public ValueRange range(TemporalField field) {
    if (field instanceof ChronoField) {
        if (field == INSTANT_SECONDS || field == OFFSET_SECONDS) {
            return field.range();
        }
        return dateTime.range(field);
    }
    return field.rangeRefinedBy(this);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:OffsetDateTime.java

示例9: range

import java.time.temporal.TemporalField; //导入方法依赖的package包/类
/**
 * Gets the range of valid values for the specified field.
 * <p>
 * The range object expresses the minimum and maximum valid values for a field.
 * This date-time is used to enhance the accuracy of the returned range.
 * If it is not possible to return the range, because the field is not supported
 * or for some other reason, an exception is thrown.
 * <p>
 * If the field is a {@link ChronoField} then the query is implemented here.
 * The {@link #isSupported(TemporalField) supported fields} will return
 * appropriate range instances.
 * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}.
 * <p>
 * If the field is not a {@code ChronoField}, then the result of this method
 * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)}
 * passing {@code this} as the argument.
 * Whether the range can be obtained is determined by the field.
 *
 * @param field  the field to query the range for, not null
 * @return the range of valid values for the field, not null
 * @throws DateTimeException if the range for the field cannot be obtained
 * @throws UnsupportedTemporalTypeException if the field is not supported
 */
@Override
public ValueRange range(TemporalField field) {
    if (field instanceof ChronoField) {
        ChronoField f = (ChronoField) field;
        return (f.isTimeBased() ? time.range(field) : date.range(field));
    }
    return field.rangeRefinedBy(this);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:32,代码来源:LocalDateTime.java


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