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


Java ReadablePartial.getField方法代码示例

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


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

示例1: set

import org.joda.time.ReadablePartial; //导入方法依赖的package包/类
/**
 * Sets a value using the specified partial instant.
 * <p>
 * The value of this field (specified by the index) will be set.
 * If the value is invalid, an exception if thrown.
 * <p>
 * If setting this field would make other fields invalid, then those fields
 * may be changed. For example if the current date is the 31st January, and
 * the month is set to February, the day would be invalid. Instead, the day
 * would be changed to the closest value - the 28th/29th February as appropriate.
 * 
 * @param partial  the partial instant
 * @param fieldIndex  the index of this field in the instant
 * @param values  the values to update
 * @param newValue  the value to set, in the units of the field
 * @return the updated values
 * @throws IllegalArgumentException if the value is invalid
 */
public int[] set(ReadablePartial partial, int fieldIndex, int[] values, int newValue) {
    FieldUtils.verifyValueBounds(this, newValue, getMinimumValue(partial, values), getMaximumValue(partial, values));
    values[fieldIndex] = newValue;
    
    // may need to adjust smaller fields
    for (int i = fieldIndex + 1; i < partial.size(); i++) {
        DateTimeField field = partial.getField(i);
        if (values[i] > field.getMaximumValue(partial, values)) {
            values[i] = field.getMaximumValue(partial, values);
        }
        if (values[i] < field.getMinimumValue(partial, values)) {
            values[i] = field.getMinimumValue(partial, values);
        }
    }
    return values;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:35,代码来源:BaseDateTimeField.java


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