/** * Construct a RemainderDateTimeField that compliments the given * DividedDateTimeField. * This constructor allows the duration field to be set. * * @param dividedField complimentary divided field, like "century()". * @param durationField the duration field * @param type the field type this field actually uses */ public RemainderDateTimeField(DividedDateTimeField dividedField, DurationField durationField, DateTimeFieldType type) { super(dividedField.getWrappedField(), type); iDivisor = dividedField.iDivisor; iDurationField = durationField; iRangeField = dividedField.iDurationField; }
/** * Construct a RemainderDateTimeField that compliments the given * DividedDateTimeField. * This constructor allows the duration field to be set. * * @param dividedField complimentary divided field, like "century()". * @param durationField the duration field * @param type the field type this field actually uses */ public RemainderDateTimeField(DividedDateTimeField dividedField, DurationField durationField, DateTimeFieldType type) { super(dividedField.getWrappedField(), type); iDivisor = dividedField.iDivisor; iDurationField = durationField; iRangeField = dividedField.iDurationField; }
/** * Add the specified amount of scaled units to the specified time * instant. The amount added may be negative. * * @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 add(long instant, int amount) { return getWrappedField().add(instant, amount * iDivisor); }
/** * Add the specified amount of scaled units to the specified time * instant. The amount added may be negative. * * @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 add(long instant, long amount) { return getWrappedField().add(instant, amount * iDivisor); }
/** * Construct a RemainderDateTimeField that compliments the given * DividedDateTimeField. * * @param dividedField complimentary divided field, like "century()". * @param type the field type this field actually uses */ public RemainderDateTimeField(DividedDateTimeField dividedField, DateTimeFieldType type) { this(dividedField, dividedField.getWrappedField().getDurationField(), type); }
public long getDifferenceAsLong(long minuendInstant, long subtrahendInstant) { return getWrappedField().getDifferenceAsLong(minuendInstant, subtrahendInstant) / iDivisor; }
/** * Construct a RemainderDateTimeField that compliments the given * DividedDateTimeField. * * @param dividedField complimentary divided field, like "century()". * @param type the field type this field actually uses */ public RemainderDateTimeField(DividedDateTimeField dividedField, DateTimeFieldType type) { this(dividedField, dividedField.getWrappedField().getDurationField(), type); }
/** * Add the specified amount of scaled units to the specified time * instant. The amount added may be negative. * * @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 add(long instant, long amount) { return getWrappedField().add(instant, amount * iDivisor); }
/** * Add the specified amount of scaled units to the specified time * instant. The amount added may be negative. * * @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 add(long instant, int amount) { return getWrappedField().add(instant, amount * iDivisor); }
public int getDifference(long minuendInstant, long subtrahendInstant) { return getWrappedField().getDifference(minuendInstant, subtrahendInstant) / iDivisor; }
/** * Get the amount of scaled units from the specified time instant. * * @param instant the time instant in millis to query. * @return the amount of scaled units extracted from the input. */ public int get(long instant) { int value = getWrappedField().get(instant); if (value >= 0) { return value / iDivisor; } else { return ((value + 1) / iDivisor) - 1; } }
/** * Get the amount of scaled units from the specified time instant. * * @param instant the time instant in millis to query. * @return the amount of scaled units extracted from the input. */ public int get(long instant) { int value = getWrappedField().get(instant); if (value >= 0) { return value / iDivisor; } else { return ((value + 1) / iDivisor) - 1; } }
public int getDifference(long minuendInstant, long subtrahendInstant) { return getWrappedField().getDifference(minuendInstant, subtrahendInstant) / iDivisor; }
public long getDifferenceAsLong(long minuendInstant, long subtrahendInstant) { return getWrappedField().getDifferenceAsLong(minuendInstant, subtrahendInstant) / iDivisor; }
/** * Set the specified amount of scaled units to the specified time instant. * * @param instant the time instant in millis to update. * @param value value of scaled units to set. * @return the updated time instant. * @throws IllegalArgumentException if value is too large or too small. */ public long set(long instant, int value) { FieldUtils.verifyValueBounds(this, value, iMin, iMax); int remainder = getRemainder(getWrappedField().get(instant)); return getWrappedField().set(instant, value * iDivisor + remainder); }
/** * Set the specified amount of scaled units to the specified time instant. * * @param instant the time instant in millis to update. * @param value value of scaled units to set. * @return the updated time instant. * @throws IllegalArgumentException if value is too large or too small. */ public long set(long instant, int value) { FieldUtils.verifyValueBounds(this, value, iMin, iMax); int remainder = getRemainder(getWrappedField().get(instant)); return getWrappedField().set(instant, value * iDivisor + remainder); }
public long roundFloor(long instant) { DateTimeField field = getWrappedField(); return field.roundFloor(field.set(instant, get(instant) * iDivisor)); }
public long remainder(long instant) { return set(instant, get(getWrappedField().remainder(instant))); }
public long remainder(long instant) { return set(instant, get(getWrappedField().remainder(instant))); }
public long roundFloor(long instant) { DateTimeField field = getWrappedField(); return field.roundFloor(field.set(instant, get(instant) * iDivisor)); }