/** * Utility method used by addWrapField implementations to ensure the new * value lies within the field's legal value range. * * @param currentValue the current value of the data, which may lie outside * the wrapped value range * @param wrapValue the value to add to current value before * wrapping. This may be negative. * @param minValue the wrap range minimum value. * @param maxValue the wrap range maximum value. This must be * greater than minValue (checked by the method). * @return the wrapped value * @throws IllegalArgumentException if minValue is greater * than or equal to maxValue */ public static int getWrappedValue(int currentValue, int wrapValue, int minValue, int maxValue) { return getWrappedValue(currentValue + wrapValue, minValue, maxValue); }
/** * Utility method used by addWrapField implementations to ensure the new * value lies within the field's legal value range. * * @param currentValue the current value of the data, which may lie outside * the wrapped value range * @param wrapValue the value to add to current value before * wrapping. This may be negative. * @param minValue the wrap range minimum value. * @param maxValue the wrap range maximum value. This must be * greater than minValue (checked by the method). * @return the wrapped value * @throws IllegalArgumentException if minValue is greater * than or equal to maxValue */ public static int getWrappedValue(int currentValue, int wrapValue, int minValue, int maxValue) { return getWrappedValue(currentValue + wrapValue, minValue, maxValue); }
/** * Add the specified amount to the specified time instant, wrapping around * within the remainder range if necessary. The amount added may be * negative. * * @param instant the time instant in millis to update. * @param amount the amount to add (can be negative). * @return the updated time instant. */ public long addWrapField(long instant, int amount) { return set(instant, FieldUtils.getWrappedValue(get(instant), amount, 0, iDivisor - 1)); }
/** * Add to the offset component of the specified time instant, * wrapping around within that component if necessary. * * @param instant the time instant in millis to update. * @param amount the amount of units to add (can be negative). * @return the updated time instant. */ public long addWrapField(long instant, int amount) { return set(instant, FieldUtils.getWrappedValue(get(instant), amount, iMin, iMax)); }
/** * Add to the scaled component of the specified time instant, * wrapping around within that component if necessary. * * @param instant the time instant in millis to update. * @param amount the amount of scaled units to add (can be negative). * @return the updated time instant. */ public long addWrapField(long instant, int amount) { return set(instant, FieldUtils.getWrappedValue(get(instant), amount, iMin, iMax)); }
/** * Add to the Month component of the specified time instant * wrapping around within that component if necessary. * * @see org.joda.time.DateTimeField#addWrapField * @param instant the time instant in millis to update. * @param months the months to add (can be negative). * @return the updated time instant. */ public long addWrapField(long instant, int months) { return set(instant, FieldUtils.getWrappedValue(get(instant), months, MIN, iMax)); }
/** * Add to the Month component of the specified time instant * wrapping around within that component if necessary. * * @see org.joda.time.DateTimeField#addWrapField * @param instant the time instant in millis to update. * @param months the months to add (can be negative). * @return the updated time instant. */ public long addWrapField(long instant, int months) { return set(instant, FieldUtils.getWrappedValue(get(instant), months, MIN, iMax)); }
/** * Add to the scaled component of the specified time instant, * wrapping around within that component if necessary. * * @param instant the time instant in millis to update. * @param amount the amount of scaled units to add (can be negative). * @return the updated time instant. */ public long addWrapField(long instant, int amount) { return set(instant, FieldUtils.getWrappedValue(get(instant), amount, iMin, iMax)); }
/** * Add to the offset component of the specified time instant, * wrapping around within that component if necessary. * * @param instant the time instant in millis to update. * @param amount the amount of units to add (can be negative). * @return the updated time instant. */ public long addWrapField(long instant, int amount) { return set(instant, FieldUtils.getWrappedValue(get(instant), amount, iMin, iMax)); }
/** * Add the specified amount to the specified time instant, wrapping around * within the remainder range if necessary. The amount added may be * negative. * * @param instant the time instant in millis to update. * @param amount the amount to add (can be negative). * @return the updated time instant. */ public long addWrapField(long instant, int amount) { return set(instant, FieldUtils.getWrappedValue(get(instant), amount, 0, iDivisor - 1)); }
public long addWrapField(long instant, int years) { if (years == 0) { return instant; } // Return newly calculated millis value int thisYear = iChronology.getYear(instant); int wrappedYear = FieldUtils.getWrappedValue (thisYear, years, iChronology.getMinYear(), iChronology.getMaxYear()); return set(instant, wrappedYear); }
public long addWrapField(long instant, int years) { if (years == 0) { return instant; } // Return newly calculated millis value int thisYear = iChronology.getYear(instant); int wrappedYear = FieldUtils.getWrappedValue (thisYear, years, iChronology.getMinYear(), iChronology.getMaxYear()); return set(instant, wrappedYear); }
/** * Add to the component of the specified time instant, wrapping around * within that component if necessary. * * @param instant the milliseconds from 1970-01-01T00:00:00Z to add to * @param amount the amount of units to add (can be negative). * @return the updated time instant. */ public long addWrapField(long instant, int amount) { int thisValue = get(instant); int wrappedValue = FieldUtils.getWrappedValue (thisValue, amount, getMinimumValue(), getMaximumValue()); // copy code from set() to avoid repeat call to get() return instant + (wrappedValue - thisValue) * getUnitMillis(); }
/** * Add to the component of the specified time instant, wrapping around * within that component if necessary. * * @param instant the milliseconds from 1970-01-01T00:00:00Z to add to * @param amount the amount of units to add (can be negative). * @return the updated time instant. */ public long addWrapField(long instant, int amount) { int thisValue = get(instant); int wrappedValue = FieldUtils.getWrappedValue (thisValue, amount, getMinimumValue(), getMaximumValue()); // copy code from set() to avoid repeat call to get() return instant + (wrappedValue - thisValue) * getUnitMillis(); }
int wrapped = FieldUtils.getWrappedValue (current, valueToAdd, getMinimumValue(instant), getMaximumValue(instant)); return set(instant, fieldIndex, values, wrapped); // adjusts smaller fields
int wrapped = FieldUtils.getWrappedValue (current, valueToAdd, getMinimumValue(instant), getMaximumValue(instant)); return set(instant, fieldIndex, values, wrapped); // adjusts smaller fields
/** * Adds a value (which may be negative) to the instant value, * wrapping within this field. * <p> * The value will be added to this field. If the value is too large to be * added solely to this field then it wraps. Larger fields are always * unaffected. Smaller fields should be unaffected, except where the * result would be an invalid value for a smaller field. In this case the * smaller field is adjusted to be in range. * <p> * For example, in the ISO chronology:<br> * 2000-08-20 addWrapField six months is 2000-02-20<br> * 2000-08-20 addWrapField twenty months is 2000-04-20<br> * 2000-08-20 addWrapField minus nine months is 2000-11-20<br> * 2001-01-31 addWrapField one month is 2001-02-28<br> * 2001-01-31 addWrapField two months is 2001-03-31<br> * <p> * The default implementation internally calls set. Subclasses are * encouraged to provide a more efficient implementation. * * @param instant the milliseconds from 1970-01-01T00:00:00Z to add to * @param value the value to add, in the units of the field * @return the updated milliseconds */ public long addWrapField(long instant, int value) { int current = get(instant); int wrapped = FieldUtils.getWrappedValue (current, value, getMinimumValue(instant), getMaximumValue(instant)); return set(instant, wrapped); }
/** * Adds a value (which may be negative) to the instant value, * wrapping within this field. * <p> * The value will be added to this field. If the value is too large to be * added solely to this field then it wraps. Larger fields are always * unaffected. Smaller fields should be unaffected, except where the * result would be an invalid value for a smaller field. In this case the * smaller field is adjusted to be in range. * <p> * For example, in the ISO chronology:<br> * 2000-08-20 addWrapField six months is 2000-02-20<br> * 2000-08-20 addWrapField twenty months is 2000-04-20<br> * 2000-08-20 addWrapField minus nine months is 2000-11-20<br> * 2001-01-31 addWrapField one month is 2001-02-28<br> * 2001-01-31 addWrapField two months is 2001-03-31<br> * <p> * The default implementation internally calls set. Subclasses are * encouraged to provide a more efficient implementation. * * @param instant the milliseconds from 1970-01-01T00:00:00Z to add to * @param value the value to add, in the units of the field * @return the updated milliseconds */ public long addWrapField(long instant, int value) { int current = get(instant); int wrapped = FieldUtils.getWrappedValue (current, value, getMinimumValue(instant), getMaximumValue(instant)); return set(instant, wrapped); }
/** * Add to the scaled component of the specified time instant, * wrapping around within that component if necessary. * * @param instant the time instant in millis to update. * @param amount the amount of scaled units to add (can be negative). * @return the updated time instant. */ public long addWrapField(long instant, int amount) { return set(instant, FieldUtils.getWrappedValue(get(instant), amount, iMin, iMax)); }
public long addWrapField(long instant, int years) { if (years == 0) { return instant; } // Return newly calculated millis value int thisYear = iChronology.getYear(instant); int wrappedYear = FieldUtils.getWrappedValue (thisYear, years, iChronology.getMinYear(), iChronology.getMaxYear()); return set(instant, wrappedYear); }