Example usage for org.joda.time DateTime plusWeeks

List of usage examples for org.joda.time DateTime plusWeeks

Introduction

In this page you can find the example usage for org.joda.time DateTime plusWeeks.

Prototype

public DateTime plusWeeks(int weeks) 

Source Link

Document

Returns a copy of this datetime plus the specified number of weeks.

Usage

From source file:org.mifos.dmt.business.Meetings.schedule.WeeklySchedule.java

License:Open Source License

public void generateSchedule(int numberOfDates) {
    numberOfDates--;/*from   w  w  w  . jav a  2 s.c om*/
    getMeetingStartDate();
    fastForwardTillDisbursement();
    DateTime temp = this.startDate;
    Date tempIns;
    for (int i = 0; i <= numberOfDates; i++) {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        tempIns = getWorkingDay(temp).toDate();
        this.scheduleList.add(formatter.format(tempIns));
        temp = temp.plusWeeks(this.recAfter);
    }
}

From source file:org.mifos.schedule.internal.WeeklyScheduledEvent.java

License:Open Source License

@Override
public DateTime nextEventDateAfter(final DateTime startingDate) {
    return startingDate.plusWeeks(every).withDayOfWeek(dayOfWeek);
}

From source file:org.mifos.schedule.internal.WeeklyScheduledEvent.java

License:Open Source License

@Override
public DateTime rollFrowardDateByFrequency(DateTime date) {
    return date.plusWeeks(this.every);
}

From source file:org.nuxeo.elasticsearch.aggregate.DateHelper.java

License:Apache License

private static DateTime plusDurationAsExpression(DateTime origin, String duration) {
    int k = getFactor(duration);
    switch (duration.substring(duration.length() - 1, duration.length())) {
    case "s":
        return origin.plusSeconds(k);
    case "m":
        return origin.plusMinutes(k);
    case "h":
        return origin.plusHours(k);
    case "d":
        return origin.plusDays(k);
    case "w":
        return origin.plusWeeks(k);
    case "M":
        return origin.plusMonths(k);
    case "y":
        return origin.plusYears(k);
    }//from   ww  w . j  av a2  s .  c om
    return invalid(duration);
}

From source file:org.nuxeo.elasticsearch.aggregate.DateHelper.java

License:Apache License

private static DateTime plusDurationAsNoun(DateTime origin, String duration) {
    switch (duration.toLowerCase()) {
    case "second":
        return origin.plusSeconds(1);
    case "minute":
        return origin.plusMinutes(1);
    case "hour":
        return origin.plusHours(1);
    case "day":
        return origin.plusDays(1);
    case "week":
        return origin.plusWeeks(1);
    case "month":
        return origin.plusMonths(1);
    case "quarter":
        return origin.plusMonths(3);
    case "year":
        return origin.plusYears(1);
    }//from w ww.  j  a  v a 2 s .com
    return invalid(duration);
}

From source file:org.obm.imap.archive.services.SchedulingDatesService.java

License:Open Source License

private DateTime weeklyNextTreatmentDate(SchedulingConfiguration schedulingConfiguration,
        DateTime currentDateTime, DateTime currentDateWithScheduledTime) {
    DateTime dayOfWeek = currentDateWithScheduledTime
            .withDayOfWeek(schedulingConfiguration.getDayOfWeek().getSpecificationValue());
    if (dayOfWeek.isAfter(currentDateTime)) {
        return dayOfWeek;
    }/*from   ww w  . j a  v  a  2  s.  c  o  m*/
    return dayOfWeek.plusWeeks(1);
}

From source file:org.opencastproject.util.DateTimeSupport.java

License:Educational Community License

/**
 * Forward to the next week day./*  w  w w  .  ja  va 2 s.  co  m*/
 * <p/>
 * If it's Monday forwarding to Tuesday will add 1 day. If it's Friday forwarding to Thursday will go to next week's
 * Thursday which is adding 6 days. Forward to Monday if on Monday simply returns <code>time</code>.
 *
 * @param weekDay
 *          like described in {@link org.joda.time.DateTimeConstants}
 */
public static DateTime toNextWeekDay(DateTime time, int weekDay) {
    return time.getDayOfWeek() <= weekDay ? time.withDayOfWeek(weekDay)
            : time.plusWeeks(1).withDayOfWeek(weekDay);
}

From source file:org.openvpms.archetype.i18n.time.DateDurationFormatter.java

License:Open Source License

/**
 * Formats the duration between two timestamps.
 * <p/>/*from  w  ww .j a  v a  2 s.c om*/
 * NOTE: this currently doesn't do anything sensible for from > to. Possible solution would be to simply
 * reverse the times, and then prepend a - between each field using  the
 *
 * @param from the starting time
 * @param to   the ending time
 * @return the formatted duration
 */
protected String format(DateTime from, DateTime to) {
    int years = 0;
    int months = 0;
    int weeks = 0;
    int days = 0;
    int hours = 0;
    int minutes = 0;

    DateTime start = from;
    if (showYears) {
        years = Years.yearsBetween(start, to).getYears();
        start = start.plusYears(years);
    }
    if (showMonths) {
        months = Months.monthsBetween(start, to).getMonths();
        start = start.plusMonths(months);
    }
    if (showWeeks) {
        weeks = Weeks.weeksBetween(start, to).getWeeks();
        start = start.plusWeeks(weeks);
    }
    if (showDays) {
        days = Days.daysBetween(start, to).getDays();
        start = start.plusDays(days);
    }
    if (showHours) {
        hours = Hours.hoursBetween(start, to).getHours();
        start = start.plusHours(hours);
    }
    if (showMinutes) {
        minutes = Minutes.minutesBetween(start, to).getMinutes();
    }

    Period period = new Period(years, months, weeks, days, hours, minutes, 0, 0);
    return formatter.print(period);
}

From source file:org.terasoluna.tourreservation.app.searchtour.SearchTourController.java

License:Apache License

/**
 * pre-initialization of form backed bean
 * @return/*from  w  w w.j  av  a  2s  . com*/
 */
@ModelAttribute
public SearchTourForm setUpSearchTourForm() {
    SearchTourForm searchTourForm = new SearchTourForm();
    DateTime dateTime = dateFactory.newDateTime();
    DateTime nextWeekDate = dateTime.plusWeeks(1);
    searchTourForm.setDepYear(nextWeekDate.getYear());
    searchTourForm.setDepMonth(nextWeekDate.getMonthOfYear());
    searchTourForm.setDepDay(nextWeekDate.getDayOfMonth());

    log.debug("populate form {}", searchTourForm);
    return searchTourForm;
}

From source file:projectresurrection.Schedule.java

public void run() {
    while (true) {
        DateTime date = Eve.clock.getCurrent();
        try {/*from   w w w. j  a  v  a2s  . c  om*/
            for (int i = 0; i < container.get(0).size(); i++) {
                DateTime setDate = new DateTime(container.get(0).get(i).get(1));
                if (date.getMillis() > setDate.getMillis()) {
                    Eve.addCommand(container.get(0).get(i).get(2).toString());
                    container.get(0).remove(i);
                    save();
                }
            }
            for (int i = 0; i < container.get(1).size(); i++) {
                DateTime setDate = new DateTime(container.get(1).get(i).get(1));
                if (date.getMillis() > setDate.getMillis()) {
                    announce(container.get(1).get(i).get(0).toString());
                    container.get(1).remove(i);
                    save();
                }
            }
            for (int i = 0; i < container.get(2).size(); i++) {
                DateTime setDate = new DateTime(container.get(2).get(i).get(1));
                if (date.getMillis() > setDate.getMillis()) {
                    announce(container.get(2).get(i).get(0).toString());
                    DateTime temp = new DateTime(container.get(2).get(i).get(1));
                    container.get(2).get(i).remove(1);
                    switch (container.get(2).get(i).get(1).toString()) {
                    case "Annual":
                        container.get(2).get(i).add(1, new DateTime(temp.plusYears(1)));
                        break;
                    case "Bi-annaul":
                        container.get(2).get(i).add(1, new DateTime(temp.plusMonths(6)));
                        break;
                    case "Monthly":
                        container.get(2).get(i).add(1, new DateTime(temp.plusMonths(1)));
                        break;
                    case "Weekly":
                        container.get(2).get(i).add(1, new DateTime(temp.plusWeeks(1)));
                        break;
                    case "Daily":
                        container.get(2).get(i).add(1, new DateTime(temp.plusDays(1)));
                        break;
                    }
                    save();
                }
            }
            Thread.sleep(1000);
        } catch (Exception e) {
            Thread.currentThread().interrupt();
        }
    }
}