Package org.joda.time

Examples of org.joda.time.Interval


        }

        DateTime startTime = new DateTime(baseDate.plusMinutes(readingInterval * 4));
        DateTime endTime = new DateTime(baseDate.plusMinutes(readingInterval * 6));
        Duration duration = new Duration(startTime, endTime);
        Interval interval = new Interval(startTime, duration);

        List<Reading> returnedReadings = persistor.querySensorReadingsByInterval(sensorId1, interval, 10);

        assertEquals(expectedReadings.size(), returnedReadings.size());

        for (Reading expectedReading : expectedReadings) {
            log.info("Sensor1: " + expectedReading);
            assertTrue(returnedReadings.contains(expectedReading));
        }

        expectedReadings = new ArrayList<Reading>();
        for (int ii = 0; ii < 4; ii++) {
            BigDecimal temperature = new BigDecimal(195 - ii).movePointLeft(1);
            expectedReadings.add(new Reading(sensorId2, baseDate.plusMinutes(readingInterval * ii),
                    temperature, 24, "ESE", BigInteger.valueOf(17L), false));
        }

        startTime = new DateTime(baseDate);
        endTime = new DateTime(baseDate.plusMinutes(readingInterval * 3));
        duration = new Duration(startTime, endTime);
        interval = new Interval(startTime, duration);

        returnedReadings = persistor.querySensorReadingsByInterval(sensorId2, interval, 10);

        assertEquals(expectedReadings.size(), returnedReadings.size());

View Full Code Here


    if (interval == null) {
      return true;
    }

    Interval requestInterval = (Interval) line.getValue(LogConstants.INTERVAL);

    if (requestInterval == null) {
      return false;
    }

    return requestInterval.overlaps(interval) || requestInterval.abuts(interval);
  }
View Full Code Here

      return null;
    }

    DateTime t = (DateTime) line.getValue(LogConstants.DATE);

    return new Interval(from.toDateTime(t), to.toDateTime(t));
  }
View Full Code Here

        this.availableRanges.add(range);
    }
   
    public long allocateWork(long startTime, long duration) {
        AllocatedWork allocatedWork = new AllocatedWork(duration);
        Interval previousRange = null;
        for (Range range : availableRanges) {
            if (range.contains(startTime)) {
              
                allocatedWork.merge(range.allocate(startTime, duration));
               
                if (allocatedWork.isAllocated()) {
                    break;
                } else {
                   
                }
               
                previousRange = range.getInterval();
            } else if (!allocatedWork.isAllocated()) {
                long gap = 0;
                if (previousRange != null) {
                    gap = previousRange.gap(range.getInterval()).toDurationMillis();
                    allocatedWork.setWaitTime(allocatedWork.getWaitTime() + gap);
                }
                allocatedWork.merge(range.allocate(range.getInterval().getStartMillis(), duration-allocatedWork.getAllocatedTime()));
            }
        }
View Full Code Here

        localCalendar.set(Calendar.MINUTE, 0);
        long startInstant = localCalendar.getTimeInMillis();
       
        localCalendar.set(Calendar.HOUR_OF_DAY, end);
        long endInstant = localCalendar.getTimeInMillis();
        interval = new Interval(startInstant, endInstant);
       
        return interval.contains(time);
       
    }
View Full Code Here

      .getPerspectiveRegistry().getPerspectives()[1];
  private PerspectiveEvent event = createEvent(new Interval(0, 1));

  @Test(expected = NullPointerException.class)
  public void testConstructor_withPerspectiveNull() {
    new PerspectiveEvent(new Interval(0, 1), null);
  }
View Full Code Here

    return win;
  }

  @Test(expected = NullPointerException.class)
  public void testContructor_withPartNull() {
    new PartEvent(new Interval(0, 1), null);
  }
View Full Code Here

*/
public class FileEventTest extends ContinuousEventTest {

  @Test(expected = NullPointerException.class)
  public void testContructor_fileIdNull() {
    createEvent(new Interval(0, 1), null);
  }
View Full Code Here

  }

  @Test
  public void testGetFilePath() {
    IPath path = Path.fromPortableString("/project/folder/me.txt");
    FileEvent event = createEvent(new Interval(0, 1), path);
    assertEquals(path, event.getFilePath());
  }
View Full Code Here

*/
public class ContinuousEventTest extends DiscreteEventTest {

  @Test(expected = NullPointerException.class)
  public void testConstructor_argNull() {
    Interval interval = null;
    createEvent(interval);
  }
View Full Code Here

TOP

Related Classes of org.joda.time.Interval

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.