/** * Sets all the fields in one go from a millisecond interval using ISOChronology * and dividing the fields using the period type. * * @param startInstant interval start, in milliseconds * @param endInstant interval end, in milliseconds * @throws ArithmeticException if the set exceeds the capacity of the period */ public void setPeriod(long startInstant, long endInstant) { setPeriod(startInstant, endInstant, null); }
/** * Sets all the fields in one go from a millisecond duration dividing the * fields using the period type. * <p> * When dividing the duration, only precise fields in the period type will be used. * For large durations, all the remaining duration will be stored in the largest * available precise field. * * @param duration the duration, in milliseconds * @throws ArithmeticException if the set exceeds the capacity of the period */ public void setPeriod(long duration) { setPeriod(duration, null); }
/** * Sets all the fields in one go from a millisecond interval using ISOChronology * and dividing the fields using the period type. * * @param startInstant interval start, in milliseconds * @param endInstant interval end, in milliseconds * @throws ArithmeticException if the set exceeds the capacity of the period */ public void setPeriod(long startInstant, long endInstant) { setPeriod(startInstant, endInstant, null); }
/** * Sets all the fields in one go from a duration dividing the * fields using the period type. * <p> * When dividing the duration, only precise fields in the period type will be used. * For large durations, all the remaining duration will be stored in the largest * available precise field. * * @param duration the duration to set, null means zero length * @throws ArithmeticException if the set exceeds the capacity of the period */ public void setPeriod(ReadableDuration duration) { setPeriod(duration, null); }
/** * Sets all the fields in one go from a duration dividing the * fields using the period type. * <p> * When dividing the duration, only precise fields in the period type will be used. * For large durations, all the remaining duration will be stored in the largest * available precise field. * * @param duration the duration to set, null means zero length * @throws ArithmeticException if the set exceeds the capacity of the period */ public void setPeriod(ReadableDuration duration) { setPeriod(duration, null); }
/** * Sets all the fields in one go from a millisecond duration dividing the * fields using the period type. * <p> * When dividing the duration, only precise fields in the period type will be used. * For large durations, all the remaining duration will be stored in the largest * available precise field. * * @param duration the duration, in milliseconds * @throws ArithmeticException if the set exceeds the capacity of the period */ public void setPeriod(long duration) { setPeriod(duration, null); }
/** * Sets all the fields in one go from a duration dividing the * fields using the period type. * <p> * When dividing the duration, only precise fields in the period type will be used. * For large durations, all the remaining duration will be stored in the largest * available precise field. * * @param duration the duration to set, null means zero length * @param chrono the chronology to use, null means ISO default * @throws ArithmeticException if the set exceeds the capacity of the period */ public void setPeriod(ReadableDuration duration, Chronology chrono) { long durationMillis = DateTimeUtils.getDurationMillis(duration); setPeriod(durationMillis, chrono); }
/** * Sets all the fields in one go from a duration dividing the * fields using the period type. * <p> * When dividing the duration, only precise fields in the period type will be used. * For large durations, all the remaining duration will be stored in the largest * available precise field. * * @param duration the duration to set, null means zero length * @param chrono the chronology to use, null means ISO default * @throws ArithmeticException if the set exceeds the capacity of the period */ public void setPeriod(ReadableDuration duration, Chronology chrono) { long durationMillis = DateTimeUtils.getDurationMillis(duration); setPeriod(durationMillis, chrono); }
/** * Sets all the fields in one go from two instants representing an interval. * <p> * The chronology of the start instant is used, unless that is null when the * chronology of the end instant is used instead. * * @param start the start instant, null means now * @param end the end instant, null means now * @throws ArithmeticException if the set exceeds the capacity of the period */ public void setPeriod(ReadableInstant start, ReadableInstant end) { if (start == end) { setPeriod(0L); } else { long startMillis = DateTimeUtils.getInstantMillis(start); long endMillis = DateTimeUtils.getInstantMillis(end); Chronology chrono = DateTimeUtils.getIntervalChronology(start, end); setPeriod(startMillis, endMillis, chrono); } }
/** * Sets all the fields in one go from two instants representing an interval. * <p> * The chronology of the start instant is used, unless that is null when the * chronology of the end instant is used instead. * * @param start the start instant, null means now * @param end the end instant, null means now * @throws ArithmeticException if the set exceeds the capacity of the period */ public void setPeriod(ReadableInstant start, ReadableInstant end) { if (start == end) { setPeriod(0L); } else { long startMillis = DateTimeUtils.getInstantMillis(start); long endMillis = DateTimeUtils.getInstantMillis(end); Chronology chrono = DateTimeUtils.getIntervalChronology(start, end); setPeriod(startMillis, endMillis, chrono); } }
/** * Sets all the fields in one go from an interval using the ISO chronology * and dividing the fields using the period type. * * @param interval the interval to set, null means zero length * @throws ArithmeticException if the set exceeds the capacity of the period */ public void setPeriod(ReadableInterval interval) { if (interval == null) { setPeriod(0L); } else { Chronology chrono = DateTimeUtils.getChronology(interval.getChronology()); setPeriod(interval.getStartMillis(), interval.getEndMillis(), chrono); } }
/** * Sets all the fields in one go from an interval using the ISO chronology * and dividing the fields using the period type. * * @param interval the interval to set, null means zero length * @throws ArithmeticException if the set exceeds the capacity of the period */ public void setPeriod(ReadableInterval interval) { if (interval == null) { setPeriod(0L); } else { Chronology chrono = DateTimeUtils.getChronology(interval.getChronology()); setPeriod(interval.getStartMillis(), interval.getEndMillis(), chrono); } }
/** * Sets all the fields in one go from a millisecond interval using ISOChronology * and dividing the fields using the period type. * * @param startInstant interval start, in milliseconds * @param endInstant interval end, in milliseconds * @throws ArithmeticException if the set exceeds the capacity of the period */ public void setPeriod(long startInstant, long endInstant) { setPeriod(startInstant, endInstant, null); }
/** * Sets all the fields in one go from a millisecond duration dividing the * fields using the period type. * <p> * When dividing the duration, only precise fields in the period type will be used. * For large durations, all the remaining duration will be stored in the largest * available precise field. * * @param duration the duration, in milliseconds * @throws ArithmeticException if the set exceeds the capacity of the period */ public void setPeriod(long duration) { setPeriod(duration, null); }
/** * Sets all the fields in one go from a duration dividing the * fields using the period type. * <p> * When dividing the duration, only precise fields in the period type will be used. * For large durations, all the remaining duration will be stored in the largest * available precise field. * * @param duration the duration to set, null means zero length * @throws ArithmeticException if the set exceeds the capacity of the period */ public void setPeriod(ReadableDuration duration) { setPeriod(duration, null); }
/** * Adds to each field of this period. * * @param years amount of years to add to this period, which must be zero if unsupported * @param months amount of months to add to this period, which must be zero if unsupported * @param weeks amount of weeks to add to this period, which must be zero if unsupported * @param days amount of days to add to this period, which must be zero if unsupported * @param hours amount of hours to add to this period, which must be zero if unsupported * @param minutes amount of minutes to add to this period, which must be zero if unsupported * @param seconds amount of seconds to add to this period, which must be zero if unsupported * @param millis amount of milliseconds to add to this period, which must be zero if unsupported * @throws IllegalArgumentException if the period being added contains a field * not supported by this period * @throws ArithmeticException if the addition exceeds the capacity of the period */ public void add(int years, int months, int weeks, int days, int hours, int minutes, int seconds, int millis) { setPeriod( FieldUtils.safeAdd(getYears(), years), FieldUtils.safeAdd(getMonths(), months), FieldUtils.safeAdd(getWeeks(), weeks), FieldUtils.safeAdd(getDays(), days), FieldUtils.safeAdd(getHours(), hours), FieldUtils.safeAdd(getMinutes(), minutes), FieldUtils.safeAdd(getSeconds(), seconds), FieldUtils.safeAdd(getMillis(), millis) ); }
/** * Adds to each field of this period. * * @param years amount of years to add to this period, which must be zero if unsupported * @param months amount of months to add to this period, which must be zero if unsupported * @param weeks amount of weeks to add to this period, which must be zero if unsupported * @param days amount of days to add to this period, which must be zero if unsupported * @param hours amount of hours to add to this period, which must be zero if unsupported * @param minutes amount of minutes to add to this period, which must be zero if unsupported * @param seconds amount of seconds to add to this period, which must be zero if unsupported * @param millis amount of milliseconds to add to this period, which must be zero if unsupported * @throws IllegalArgumentException if the period being added contains a field * not supported by this period * @throws ArithmeticException if the addition exceeds the capacity of the period */ public void add(int years, int months, int weeks, int days, int hours, int minutes, int seconds, int millis) { setPeriod( FieldUtils.safeAdd(getYears(), years), FieldUtils.safeAdd(getMonths(), months), FieldUtils.safeAdd(getWeeks(), weeks), FieldUtils.safeAdd(getDays(), days), FieldUtils.safeAdd(getHours(), hours), FieldUtils.safeAdd(getMinutes(), minutes), FieldUtils.safeAdd(getSeconds(), seconds), FieldUtils.safeAdd(getMillis(), millis) ); }
/** * Sets all the fields in one go from a duration dividing the * fields using the period type. * <p> * When dividing the duration, only precise fields in the period type will be used. * For large durations, all the remaining duration will be stored in the largest * available precise field. * * @param duration the duration to set, null means zero length * @param chrono the chronology to use, null means ISO default * @throws ArithmeticException if the set exceeds the capacity of the period */ public void setPeriod(ReadableDuration duration, Chronology chrono) { long durationMillis = DateTimeUtils.getDurationMillis(duration); setPeriod(durationMillis, chrono); }
/** * Sets all the fields in one go from two instants representing an interval. * <p> * The chronology of the start instant is used, unless that is null when the * chronology of the end instant is used instead. * * @param start the start instant, null means now * @param end the end instant, null means now * @throws ArithmeticException if the set exceeds the capacity of the period */ public void setPeriod(ReadableInstant start, ReadableInstant end) { if (start == end) { setPeriod(0L); } else { long startMillis = DateTimeUtils.getInstantMillis(start); long endMillis = DateTimeUtils.getInstantMillis(end); Chronology chrono = DateTimeUtils.getIntervalChronology(start, end); setPeriod(startMillis, endMillis, chrono); } }
/** * Sets all the fields in one go from an interval using the ISO chronology * and dividing the fields using the period type. * * @param interval the interval to set, null means zero length * @throws ArithmeticException if the set exceeds the capacity of the period */ public void setPeriod(ReadableInterval interval) { if (interval == null) { setPeriod(0L); } else { Chronology chrono = DateTimeUtils.getChronology(interval.getChronology()); setPeriod(interval.getStartMillis(), interval.getEndMillis(), chrono); } }