/** * Get the amount of fractional units from the specified time instant. * * @param instant the milliseconds from 1970-01-01T00:00:00Z to query * @return the amount of fractional units extracted from the input. */ public int get(long instant) { if (instant >= 0) { return (int) ((instant / getUnitMillis()) % iRange); } else { return iRange - 1 + (int) (((instant + 1) / getUnitMillis()) % iRange); } }
/** * Get the amount of fractional units from the specified time instant. * * @param instant the milliseconds from 1970-01-01T00:00:00Z to query * @return the amount of fractional units extracted from the input. */ public int get(long instant) { if (instant >= 0) { return (int) ((instant / getUnitMillis()) % iRange); } else { return iRange - 1 + (int) (((instant + 1) / getUnitMillis()) % iRange); } }
/** * Constructor. * * @param type the field type this field uses * @param unit precise unit duration, like "seconds()". * @param range precise range duration, preferably a multiple of the unit, * like "minutes()". * @throws IllegalArgumentException if either duration field is imprecise * @throws IllegalArgumentException if unit milliseconds is less than one * or effective value range is less than two. */ public PreciseDateTimeField(DateTimeFieldType type, DurationField unit, DurationField range) { super(type, unit); if (!range.isPrecise()) { throw new IllegalArgumentException("Range duration field must be precise"); } long rangeMillis = range.getUnitMillis(); iRange = (int)(rangeMillis / getUnitMillis()); if (iRange < 2) { throw new IllegalArgumentException("The effective range must be at least 2"); } iRangeField = range; }
/** * Constructor. * * @param type the field type this field uses * @param unit precise unit duration, like "seconds()". * @param range precise range duration, preferably a multiple of the unit, * like "minutes()". * @throws IllegalArgumentException if either duration field is imprecise * @throws IllegalArgumentException if unit milliseconds is less than one * or effective value range is less than two. */ public PreciseDateTimeField(DateTimeFieldType type, DurationField unit, DurationField range) { super(type, unit); if (!range.isPrecise()) { throw new IllegalArgumentException("Range duration field must be precise"); } long rangeMillis = range.getUnitMillis(); iRange = (int)(rangeMillis / getUnitMillis()); if (iRange < 2) { throw new IllegalArgumentException("The effective range must be at least 2"); } iRangeField = range; }
/** * 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(); }
/** * Get the amount of fractional units from the specified time instant. * * @param instant the milliseconds from 1970-01-01T00:00:00Z to query * @return the amount of fractional units extracted from the input. */ public int get(long instant) { if (instant >= 0) { return (int) ((instant / getUnitMillis()) % iRange); } else { return iRange - 1 + (int) (((instant + 1) / getUnitMillis()) % iRange); } }
/** * Constructor. * * @param type the field type this field uses * @param unit precise unit duration, like "seconds()". * @param range precise range duration, preferably a multiple of the unit, * like "minutes()". * @throws IllegalArgumentException if either duration field is imprecise * @throws IllegalArgumentException if unit milliseconds is less than one * or effective value range is less than two. */ public PreciseDateTimeField(DateTimeFieldType type, DurationField unit, DurationField range) { super(type, unit); if (!range.isPrecise()) { throw new IllegalArgumentException("Range duration field must be precise"); } long rangeMillis = range.getUnitMillis(); iRange = (int)(rangeMillis / getUnitMillis()); if (iRange < 2) { throw new IllegalArgumentException("The effective range must be at least 2"); } iRangeField = range; }
/** * 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(); }
/** * Get the amount of fractional units from the specified time instant. * * @param instant the milliseconds from 1970-01-01T00:00:00Z to query * @return the amount of fractional units extracted from the input. */ public int get(long instant) { if (instant >= 0) { return (int) ((instant / getUnitMillis()) % iRange); } else { return iRange - 1 + (int) (((instant + 1) / getUnitMillis()) % iRange); } }
/** * Get the amount of fractional units from the specified time instant. * * @param instant the milliseconds from 1970-01-01T00:00:00Z to query * @return the amount of fractional units extracted from the input. */ public int get(long instant) { if (instant >= 0) { return (int) ((instant / getUnitMillis()) % iRange); } else { return iRange - 1 + (int) (((instant + 1) / getUnitMillis()) % iRange); } }
/** * Get the amount of fractional units from the specified time instant. * * @param instant the milliseconds from 1970-01-01T00:00:00Z to query * @return the amount of fractional units extracted from the input. */ public int get(long instant) { if (instant >= 0) { return (int) ((instant / getUnitMillis()) % iRange); } else { return iRange - 1 + (int) (((instant + 1) / getUnitMillis()) % iRange); } }
/** * Get the amount of fractional units from the specified time instant. * * @param instant the milliseconds from 1970-01-01T00:00:00Z to query * @return the amount of fractional units extracted from the input. */ public int get(long instant) { if (instant >= 0) { return (int) ((instant / getUnitMillis()) % iRange); } else { return iRange - 1 + (int) (((instant + 1) / getUnitMillis()) % iRange); } }
/** * Get the amount of fractional units from the specified time instant. * * @param instant the milliseconds from 1970-01-01T00:00:00Z to query * @return the amount of fractional units extracted from the input. */ public int get(long instant) { if (instant >= 0) { return (int) ((instant / getUnitMillis()) % iRange); } else { return iRange - 1 + (int) (((instant + 1) / getUnitMillis()) % iRange); } }
/** * Get the amount of fractional units from the specified time instant. * * @param instant the milliseconds from 1970-01-01T00:00:00Z to query * @return the amount of fractional units extracted from the input. */ public int get(long instant) { if (instant >= 0) { return (int) ((instant / getUnitMillis()) % iRange); } else { return iRange - 1 + (int) (((instant + 1) / getUnitMillis()) % iRange); } }
/** * Get the amount of fractional units from the specified time instant. * * @param instant the milliseconds from 1970-01-01T00:00:00Z to query * @return the amount of fractional units extracted from the input. */ public int get(long instant) { if (instant >= 0) { return (int) ((instant / getUnitMillis()) % iRange); } else { return iRange - 1 + (int) (((instant + 1) / getUnitMillis()) % iRange); } }
/** * Get the amount of fractional units from the specified time instant. * * @param instant the milliseconds from 1970-01-01T00:00:00Z to query * @return the amount of fractional units extracted from the input. */ public int get(long instant) { if (instant >= 0) { return (int) ((instant / getUnitMillis()) % iRange); } else { return iRange - 1 + (int) (((instant + 1) / getUnitMillis()) % iRange); } }
/** * 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(); }
/** * 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(); }