public Duration calculateDurationAllIntervalsByAttributesToTime(TimeOfDay timeOfDay, Attributes attributes) { Duration totalDuration = new Duration(0); for (AttributeType attribute: attributes.getAttributes()) { TimeInterval interval = findIntervalByAttribute(attribute); if (interval != null) { if (interval.getEndTime().isBefore(timeOfDay) || interval.getEndTime().equals(timeOfDay)) { totalDuration = totalDuration.plus(interval.getDuration());
public Duration calculateDurationAllIntervalsByAttributesToTime(TimePoint timePoint, Attributes attributes) { Duration totalDuration = new Duration(0); for (AttributeType attribute : attributes.getAttributes()) { TimePoint[] timePoints = findIntervalByAttribute(attribute); if (timePoints != null) { if (timePoints[1].isBefore(timePoint)   || timePoint.isAtSameTime(timePoints[1])) { DateTime startDate = timePoints[0].getTime().toDateTimeToday(); DateTime endDate = timePoints[1].getTime().toDateTimeToday(); if (timePoints[0].isNextDay() != timePoints[1].isNextDay()) { endDate = endDate.plusDays(1); } totalDuration = totalDuration.plus(new Duration(startDate, endDate));
    public Duration calculateDurationAllIntervalsByAttributesToTime(TimeOfDay timeOfDay, Attributes attributes) {    		Duration totalDuration = new Duration(0);        for (AttributeType attribute: attributes.getAttributes()) {            TimeInterval interval = findIntervalByAttribute(attribute);            if (interval != null) {                if (interval.getEndTime().isBefore(timeOfDay) || interval.getEndTime().equals(timeOfDay)) {                    totalDuration = totalDuration.plus(interval.getDuration());                }            } else {                break;            }                   }        return totalDuration;    }