TimeInterval { public DateTime plus(DateTime instant, int multiple) { if (this == INFINITE) { throw new IllegalStateException( "plus() function is not supported on an infinite TimeInterval"); } else if (this == ZERO) { return instant; } validateMultiple(multiple); if (type == null) { return instant.plus(multiple * getLength()); } else { return instant.plus(type.toPeriod(FieldUtils.safeMultiplyToInt(multiple, getLength()))); } } private  TimeInterval(TimeIntervalType type, long length); static TimeInterval withMillis(long millis); static TimeInterval withTypeAndLength(TimeIntervalType type, int length); DateTime getIntervalStart(DateTime instant); DateTime plus(DateTime instant, int multiple); DateTime minus(DateTime instant, int multiple); boolean isPeriod(); @JsonProperty("length") long getLength(); @JsonProperty("type") TimeIntervalType getType(); @Deprecated long toApproxMillis(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static final TimeInterval INFINITE; static final TimeInterval ZERO; }
@Test( groups = "fast", expectedExceptions = {IllegalStateException.class}) public void testInfinitePlus() { TimeInterval.INFINITE.plus(new DateTime(1000), 1); }