Example usage for org.joda.time Interval getStart

List of usage examples for org.joda.time Interval getStart

Introduction

In this page you can find the example usage for org.joda.time Interval getStart.

Prototype

public DateTime getStart() 

Source Link

Document

Gets the start of this time interval, which is inclusive, as a DateTime.

Usage

From source file:com.sos.scheduler.model.objects.JodaTools.java

License:Apache License

public static DateTime getWeekdayInIntervalOrNull(Interval interval, int weekday, int which) {
    DateTime currentDate = getStartOfMonth(interval.getStart());
    DateTime result = getWeekdayInMonth(currentDate, weekday, which);
    while (!interval.contains(result)) {
        currentDate = currentDate.plusMonths(1);
        result = getWeekdayInMonth(currentDate, weekday, which);
        if (!result.isBefore(interval.getEnd()))
            return null;
    }/*from w  w w . ja  va2  s  . c  o m*/
    return result;
}

From source file:com.sos.scheduler.model.objects.JodaTools.java

License:Apache License

public static DateTime getDayInIntervalOrNull(Interval interval, int day) {
    DateTime currentDate = getStartOfMonth(interval.getStart());
    DateTime result = getDayInMonth(currentDate, day);
    while (!interval.contains(result)) {
        currentDate = currentDate.plusMonths(1);
        result = getDayInMonth(currentDate, day);
        if (!result.isBefore(interval.getEnd()))
            return null;
    }//  w ww  .j  a v a  2 s  .  com
    return result;
}

From source file:com.sos.scheduler.model.objects.JSObjDay.java

License:Apache License

@Override
public RunTimeElements getRunTimeElements(Interval timeRange) {
    RunTimeElements result = new RunTimeElements(timeRange);
    RunTimeElements work = getNextSingleStarts(timeRange.getStart());
    for (RunTimeElement runtime : work.values()) {
        DateTime date = runtime.getStartDate();
        if (timeRange.contains(date)) {
            while (timeRange.contains(date)) {
                result.add(new RunTimeElement(date, runtime.getWhenHoliday()));
                date = date.plusWeeks(1);
            }//from   w  w  w  . j  a v a2  s .  co  m
        }
    }
    //      Collections.sort(result, DateTimeComparator.getInstance());
    return result;
}

From source file:com.sos.scheduler.model.objects.JSObjHolidaysWeekdaysDay.java

License:Apache License

public List<DateTime> getDtHolidays(Interval timeRange) {
    List<DateTime> result = new ArrayList<DateTime>();
    List<DateTime> work = getNextSingleStarts(timeRange.getStart());
    for (DateTime date : work) {
        if (timeRange.contains(date)) {
            while (timeRange.contains(date)) {
                result.add(date);/*from  w w  w.j  av a2s.com*/
                date = date.plusWeeks(1);
            }
        }
    }
    Collections.sort(result, DateTimeComparator.getInstance());
    return result;
}

From source file:com.sos.scheduler.model.objects.JSObjPeriod.java

License:Apache License

@Override
public RunTimeElements getRunTimeElements(Interval timeRange) {
    RunTimeElements result = new RunTimeElements(timeRange);
    DateTime dt = getDtSingleStartOrNull(timeRange.getStart());
    if (dt != null) {
        result = new RunTimeElements(timeRange);
        if (!timeRange.contains(dt))
            dt = dt.plusDays(1);//from   www .  j  ava 2  s  .co m
        while (true) {
            if (!timeRange.contains(dt))
                break;
            result.add(new RunTimeElement(dt, getWhenHoliday()));
            dt = dt.plusDays(1);
        }
        //         Collections.sort(result, DateTimeComparator.getInstance());
    }
    return result;
}

From source file:com.sos.scheduler.model.objects.JSObjRunTime.java

License:Apache License

public List<DateTime> getDtSingleStarts(final Interval timeRange) {

    // get all runtimes one including one day before and one day after the given time range also
    // because some holiday defintion could move the calculated dates into the original timeRange given
    // in the parameter (see getStartDatesAwareHolidays)
    Interval extendedTimeRange = new Interval(timeRange.getStart().minusDays(1),
            timeRange.getEnd().plusDays(1));

    RunTimeElements runTimes = new RunTimeElements(timeRange);
    runTimes.putAll(getDtWeekdays(extendedTimeRange));
    runTimes.putAll(getDtPeriod(extendedTimeRange));
    runTimes.putAll(getDtAt(extendedTimeRange));
    runTimes.putAll(getDtDate(extendedTimeRange));
    runTimes.putAll(getDtMonthdays(extendedTimeRange));
    runTimes.putAll(getDtUltimos(extendedTimeRange));
    // the single start given in the run_time element is only relevant if no subsequent
    // period element is given.
    if (runTimes.size() == 0) {
        RunTimeElements periodStartTimes = period.getRunTimeElements(extendedTimeRange);
        runTimes.putAll(periodStartTimes);
    }/*w w  w  .  ja  v  a  2s  . c om*/

    List<DateTime> result = new ArrayList<DateTime>();
    for (DateTime d : getJsObjHolidays().getStartDatesAwareHolidays(runTimes)) {
        if (timeRange.contains(d)) // only dates inside the given time range should be in the result set
            result.add(d);
    }
    return result;
}

From source file:com.sos.scheduler.model.objects.JSObjWeekdaysDay.java

License:Apache License

@Override
public RunTimeElements getRunTimeElements(Interval timeRange) {
    RunTimeElements result = new RunTimeElements(timeRange);
    RunTimeElements work = getNextSingleStarts(timeRange.getStart());
    for (RunTimeElement runtime : work.values()) {
        DateTime date = runtime.getStartDate();
        if (timeRange.contains(date)) {
            while (timeRange.contains(date)) {
                result.add(new RunTimeElement(date, runtime.getWhenHoliday()));
                date = date.plusWeeks(1);
            }//w  w  w  . j ava 2  s. c  o  m
        }
    }
    //         Collections.sort(result, DateTimeComparator.getInstance());
    return result;
}

From source file:com.stagecents.hxt.domain.Timecard.java

License:Open Source License

public void updateHours(Activity activity, ElementType element, Interval interval) {
    LocalDate dateWorked = interval.getStart().toLocalDate();

    SummaryHours sh = getSummaryHours(dateWorked);
    if (sh == null && isEffective(dateWorked)) {
        int seq = getSummaryHoursSequence(dateWorked);
        sh = new SummaryHours(this, seq, dateWorked);
    }//from  ww w. j  a  v a 2 s .  c  o m
    sh.updateHours(activity, element, interval);
}

From source file:com.stagecents.pay.domain.ElementType.java

License:Open Source License

MultiplierValue getMultiplier(Interval interval) {
    Iterator<InputValue> iter = inputValues.iterator();
    while (iter.hasNext()) {
        InputValue iv = iter.next();//from  w ww.  j  a va2 s. c o  m
        if (iv instanceof MultiplierValue) {
            MultiplierValue mv = (MultiplierValue) iv;
            if (mv.getEffectiveDateRange() == null || mv.isEffective(interval.getStart())) {
                return mv;
            }
        }
    }
    return null;
}

From source file:com.stagecents.pay.domain.ElementType.java

License:Open Source License

MinimumCallValue getMinimumCall(Interval interval) {
    Iterator<InputValue> iter = inputValues.iterator();
    while (iter.hasNext()) {
        InputValue iv = iter.next();/*from www . jav  a  2s  . c  om*/
        if (iv instanceof MinimumCallValue) {
            MinimumCallValue mcv = (MinimumCallValue) iv;
            if (mcv.getEffectiveDateRange() == null || mcv.isEffective(interval.getStart())) {
                return mcv;
            }
        }
    }
    return null;
}