public void testConstructor_long_long_minMax() throws Throwable {
   Interval test = new Interval(Long.MIN_VALUE, Long.MAX_VALUE);
   assertEquals(Long.MIN_VALUE, test.getStartMillis());
   assertEquals(Long.MAX_VALUE, test.getEndMillis());
   assertEquals(new DateTime(Long.MIN_VALUE), test.getStart());
   assertEquals(new DateTime(Long.MAX_VALUE), test.getEnd());
   assertEquals(ISOChronology.getInstance(), test.getChronology());
   assertEquals(test, test.toInterval());
   assertEquals(
       "-292275055-05-16T16:56:25.192+00:09:21/292278994-08-17T07:12:55.807Z", test.toString());
   try {
     test.toDuration();
     fail();
   } catch (ArithmeticException ex) {
   }
   try {
     test.toDurationMillis();
     fail();
   } catch (ArithmeticException ex) {
   }
   try {
     test.toPeriod();
     fail();
   } catch (RuntimeException ex) {
   }
 }
예제 #2
0
  @Override
  public String toString() {
    String useNextText = "";
    if (!interval.getToDate().equals(useNext)) {
      useNextText = ", use next " + DateHelper.formatDateTimeInteligently(useNext);
    }

    return interval.toString() + useNextText;
  }
 public void testConstructor_long_long_max() throws Throwable {
   Interval test = new Interval(Long.MAX_VALUE - 9, Long.MAX_VALUE);
   assertEquals(Long.MAX_VALUE - 9, test.getStartMillis());
   assertEquals(Long.MAX_VALUE, test.getEndMillis());
   assertEquals(new DateTime(Long.MAX_VALUE - 9), test.getStart());
   assertEquals(new DateTime(Long.MAX_VALUE), test.getEnd());
   assertEquals(ISOChronology.getInstance(), test.getChronology());
   assertEquals(test, test.toInterval());
   assertEquals("292278994-08-17T07:12:55.798Z/292278994-08-17T07:12:55.807Z", test.toString());
   assertEquals(9, test.toDurationMillis());
   assertEquals(new Duration(9), test.toDuration());
 }
 public void testConstructor_long_long_min() throws Throwable {
   Interval test = new Interval(Long.MIN_VALUE, Long.MIN_VALUE + 9);
   assertEquals(Long.MIN_VALUE, test.getStartMillis());
   assertEquals(Long.MIN_VALUE + 9, test.getEndMillis());
   assertEquals(new DateTime(Long.MIN_VALUE), test.getStart());
   assertEquals(new DateTime(Long.MIN_VALUE + 9), test.getEnd());
   assertEquals(ISOChronology.getInstance(), test.getChronology());
   assertEquals(test, test.toInterval());
   assertEquals(
       "-292275055-05-16T16:56:25.192+00:09:21/-292275055-05-16T16:56:25.201+00:09:21",
       test.toString());
   assertEquals(9, test.toDurationMillis());
   assertEquals(new Duration(9), test.toDuration());
   assertEquals(new Period(9), test.toPeriod());
 }
 @Test
 public void testToString() {
   Interval interval = Interval.evensFromTo(0, 10);
   Assert.assertEquals("Interval from: 0 to: 10 step: 2 size: 6", interval.toString());
 }