TimeInterval { public DateTime minus(DateTime instant, int multiple) { if (this == INFINITE) { throw new IllegalStateException( "minus() function is not supported on an infinite TimeInterval"); } else if (this == ZERO) { return instant; } validateMultiple(multiple); if (type == null) { return instant.minus(multiple * getLength()); } else { return instant.minus(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 testInfiniteMinus() { DateTime testTimePDT = new DateTime(2011, 3, 13, 0, 29, 10, 101, PDT); TimeInterval.INFINITE.minus(testTimePDT, 1); }