本文整理汇总了Java中org.joda.time.DateTimeField.getMaximumValue方法的典型用法代码示例。如果您正苦于以下问题:Java DateTimeField.getMaximumValue方法的具体用法?Java DateTimeField.getMaximumValue怎么用?Java DateTimeField.getMaximumValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joda.time.DateTimeField
的用法示例。
在下文中一共展示了DateTimeField.getMaximumValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DividedDateTimeField
import org.joda.time.DateTimeField; //导入方法依赖的package包/类
/**
* Construct a DividedDateTimeField that compliments the given
* RemainderDateTimeField.
*
* @param remainderField complimentary remainder field, like "yearOfCentury()".
* @param type the field type this field will actually use
*/
public DividedDateTimeField(RemainderDateTimeField remainderField, DateTimeFieldType type) {
super(remainderField.getWrappedField(), type);
int divisor = iDivisor = remainderField.iDivisor;
iDurationField = remainderField.iRangeField;
DateTimeField field = getWrappedField();
int i = field.getMinimumValue();
int min = (i >= 0) ? i / divisor : ((i + 1) / divisor - 1);
int j = field.getMaximumValue();
int max = (j >= 0) ? j / divisor : ((j + 1) / divisor - 1);
iMin = min;
iMax = max;
}
示例2: OffsetDateTimeField
import org.joda.time.DateTimeField; //导入方法依赖的package包/类
/**
* Constructor.
*
* @param field the field to wrap, like "year()".
* @param type the field type this field actually uses
* @param offset offset to add to field values
* @param minValue minimum allowed value
* @param maxValue maximum allowed value
* @throws IllegalArgumentException if offset is zero
*/
public OffsetDateTimeField(DateTimeField field, DateTimeFieldType type, int offset,
int minValue, int maxValue) {
super(field, type);
if (offset == 0) {
throw new IllegalArgumentException("The offset cannot be zero");
}
iOffset = offset;
if (minValue < (field.getMinimumValue() + offset)) {
iMin = field.getMinimumValue() + offset;
} else {
iMin = minValue;
}
if (maxValue > (field.getMaximumValue() + offset)) {
iMax = field.getMaximumValue() + offset;
} else {
iMax = maxValue;
}
}
示例3: getMaximumValue
import org.joda.time.DateTimeField; //导入方法依赖的package包/类
public int getMaximumValue(ReadablePartial partial, int[] values) {
Chronology chrono = GJChronology.getInstanceUTC();
long instant = 0L;
for (int i = 0, isize = partial.size(); i < isize; i++) {
DateTimeField field = partial.getFieldType(i).getField(chrono);
if (values[i] <= field.getMaximumValue(instant)) {
instant = field.set(instant, values[i]);
}
}
return getMaximumValue(instant);
}
示例4: set
import org.joda.time.DateTimeField; //导入方法依赖的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;
}