/** * Sets the duration of this time interval, preserving the end instant. * * @param duration new duration for interval * @throws IllegalArgumentException if the end is before the start * @throws ArithmeticException if the start instant exceeds the capacity of a long */ public void setDurationBeforeEnd(long duration) { setStartMillis(FieldUtils.safeAdd(getEndMillis(), -duration)); }
/** * Sets the chronology of this time interval. * * @param chrono the chronology to use, null means ISO default */ public void setChronology(Chronology chrono) { super.setInterval(getStartMillis(), getEndMillis(), chrono); }
/** * Sets the start of this time interval. * * @param startInstant the start of the time interval, * millisecond instant from 1970-01-01T00:00:00Z * @throws IllegalArgumentException if the end is before the start */ public void setStartMillis(long startInstant) { super.setInterval(startInstant, getEndMillis(), getChronology()); }
/** * Sets the chronology of this time interval. * * @param chrono the chronology to use, null means ISO default */ public void setChronology(Chronology chrono) { super.setInterval(getStartMillis(), getEndMillis(), chrono); }
/** * Sets the start of this time interval. * * @param startInstant the start of the time interval, * millisecond instant from 1970-01-01T00:00:00Z * @throws IllegalArgumentException if the end is before the start */ public void setStartMillis(long startInstant) { super.setInterval(startInstant, getEndMillis(), getChronology()); }
/** * Sets the duration of this time interval, preserving the end instant. * * @param duration new duration for interval * @throws IllegalArgumentException if the end is before the start * @throws ArithmeticException if the start instant exceeds the capacity of a long */ public void setDurationBeforeEnd(long duration) { setStartMillis(FieldUtils.safeAdd(getEndMillis(), -duration)); }
/** * Sets the period of this time interval, preserving the end instant * and using the ISOChronology in the default zone for calculations. * * @param period new period for interval, null means zero length * @throws IllegalArgumentException if the end is before the start * @throws ArithmeticException if the start instant exceeds the capacity of a long */ public void setPeriodBeforeEnd(ReadablePeriod period) { if (period == null) { setStartMillis(getEndMillis()); } else { setStartMillis(getChronology().add(period, getEndMillis(), -1)); } }
/** * Sets the period of this time interval, preserving the end instant * and using the ISOChronology in the default zone for calculations. * * @param period new period for interval, null means zero length * @throws IllegalArgumentException if the end is before the start * @throws ArithmeticException if the start instant exceeds the capacity of a long */ public void setPeriodBeforeEnd(ReadablePeriod period) { if (period == null) { setStartMillis(getEndMillis()); } else { setStartMillis(getChronology().add(period, getEndMillis(), -1)); } }
/** * Sets the duration of this time interval, preserving the end instant. * * @param duration new duration for interval, null means zero length * @throws IllegalArgumentException if the end is before the start * @throws ArithmeticException if the start instant exceeds the capacity of a long */ public void setDurationBeforeEnd(ReadableDuration duration) { long durationMillis = DateTimeUtils.getDurationMillis(duration); setStartMillis(FieldUtils.safeAdd(getEndMillis(), -durationMillis)); }
/** * Sets the start of this time interval as an Instant. * * @param start the start of the time interval, null means now * @throws IllegalArgumentException if the end is before the start */ public void setStart(ReadableInstant start) { long startMillis = DateTimeUtils.getInstantMillis(start); super.setInterval(startMillis, getEndMillis(), getChronology()); }
/** * Sets the duration of this time interval, preserving the end instant. * * @param duration new duration for interval, null means zero length * @throws IllegalArgumentException if the end is before the start * @throws ArithmeticException if the start instant exceeds the capacity of a long */ public void setDurationBeforeEnd(ReadableDuration duration) { long durationMillis = DateTimeUtils.getDurationMillis(duration); setStartMillis(FieldUtils.safeAdd(getEndMillis(), -durationMillis)); }
/** * Sets the start of this time interval as an Instant. * * @param start the start of the time interval, null means now * @throws IllegalArgumentException if the end is before the start */ public void setStart(ReadableInstant start) { long startMillis = DateTimeUtils.getInstantMillis(start); super.setInterval(startMillis, getEndMillis(), getChronology()); }
/** * Constructs a time interval converting or copying from another object * that describes an interval. * * @param interval the time interval to copy * @param chrono the chronology to use, null means let converter decide * @throws IllegalArgumentException if the interval is invalid */ protected BaseInterval(Object interval, Chronology chrono) { super(); IntervalConverter converter = ConverterManager.getInstance().getIntervalConverter(interval); if (converter.isReadableInterval(interval, chrono)) { ReadableInterval input = (ReadableInterval) interval; iChronology = (chrono != null ? chrono : input.getChronology()); iStartMillis = input.getStartMillis(); iEndMillis = input.getEndMillis(); } else if (this instanceof ReadWritableInterval) { converter.setInto((ReadWritableInterval) this, interval, chrono); } else { MutableInterval mi = new MutableInterval(); converter.setInto(mi, interval, chrono); iChronology = mi.getChronology(); iStartMillis = mi.getStartMillis(); iEndMillis = mi.getEndMillis(); } checkInterval(iStartMillis, iEndMillis); }
/** * Constructs a time interval converting or copying from another object * that describes an interval. * * @param interval the time interval to copy * @param chrono the chronology to use, null means let converter decide * @throws IllegalArgumentException if the interval is invalid */ protected BaseInterval(Object interval, Chronology chrono) { super(); IntervalConverter converter = ConverterManager.getInstance().getIntervalConverter(interval); if (converter.isReadableInterval(interval, chrono)) { ReadableInterval input = (ReadableInterval) interval; iChronology = (chrono != null ? chrono : input.getChronology()); iStartMillis = input.getStartMillis(); iEndMillis = input.getEndMillis(); } else if (this instanceof ReadWritableInterval) { converter.setInto((ReadWritableInterval) this, interval, chrono); } else { MutableInterval mi = new MutableInterval(); converter.setInto(mi, interval, chrono); iChronology = mi.getChronology(); iStartMillis = mi.getStartMillis(); iEndMillis = mi.getEndMillis(); } checkInterval(iStartMillis, iEndMillis); }
/** * Sets the duration of this time interval, preserving the end instant. * * @param duration new duration for interval * @throws IllegalArgumentException if the end is before the start * @throws ArithmeticException if the start instant exceeds the capacity of a long */ public void setDurationBeforeEnd(long duration) { setStartMillis(FieldUtils.safeAdd(getEndMillis(), -duration)); }
/** * Sets the chronology of this time interval. * * @param chrono the chronology to use, null means ISO default */ public void setChronology(Chronology chrono) { super.setInterval(getStartMillis(), getEndMillis(), chrono); }
/** * Sets the start of this time interval. * * @param startInstant the start of the time interval, * millisecond instant from 1970-01-01T00:00:00Z * @throws IllegalArgumentException if the end is before the start */ public void setStartMillis(long startInstant) { super.setInterval(startInstant, getEndMillis(), getChronology()); }
/** * Sets the period of this time interval, preserving the end instant * and using the ISOChronology in the default zone for calculations. * * @param period new period for interval, null means zero length * @throws IllegalArgumentException if the end is before the start * @throws ArithmeticException if the start instant exceeds the capacity of a long */ public void setPeriodBeforeEnd(ReadablePeriod period) { if (period == null) { setStartMillis(getEndMillis()); } else { setStartMillis(getChronology().add(period, getEndMillis(), -1)); } }
/** * Sets the start of this time interval as an Instant. * * @param start the start of the time interval, null means now * @throws IllegalArgumentException if the end is before the start */ public void setStart(ReadableInstant start) { long startMillis = DateTimeUtils.getInstantMillis(start); super.setInterval(startMillis, getEndMillis(), getChronology()); }
/** * Sets the duration of this time interval, preserving the end instant. * * @param duration new duration for interval, null means zero length * @throws IllegalArgumentException if the end is before the start * @throws ArithmeticException if the start instant exceeds the capacity of a long */ public void setDurationBeforeEnd(ReadableDuration duration) { long durationMillis = DateTimeUtils.getDurationMillis(duration); setStartMillis(FieldUtils.safeAdd(getEndMillis(), -durationMillis)); }