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:io.renren.common.utils.DateUtils.java

License:Apache License

/**
 * ?/?//www  . j ava 2s. c o  m
 *
 * @param date 
 * @param weeks ?
 * @return /??
 */
public static Date addDateWeeks(Date date, int weeks) {
    DateTime dateTime = new DateTime(date);
    return dateTime.plusWeeks(weeks).toDate();
}

From source file:kr.debop4j.timeperiod.timerange.WeekRange.java

License:Apache License

/**
 * Add weeks./*  www.ja  v  a  2s  .c o  m*/
 *
 * @param weeks the weeks
 * @return the week range
 */
public WeekRange addWeeks(int weeks) {
    DateTime startOfWeek = Times.getStartOfYearWeek(getYear(), getStartWeekOfYear(), getTimeCalendar());
    return new WeekRange(startOfWeek.plusWeeks(weeks), getTimeCalendar());
}

From source file:kr.debop4j.timeperiod.timerange.WeekRangeCollection.java

License:Apache License

/**
 * Gets weeks.//ww  w .  j ava2  s.co  m
 *
 * @return the weeks
 */
public List<WeekRange> getWeeks() {
    DateTime startWeek = getStart();
    List<WeekRange> weeks = Lists.newArrayListWithCapacity(getWeekCount());

    for (int i = 0; i < getWeekCount(); i++) {
        weeks.add(new WeekRange(startWeek.plusWeeks(i), getTimeCalendar()));
    }
    return weeks;
}

From source file:kr.debop4j.timeperiod.timerange.WeekTimeRange.java

License:Apache License

private static TimeRange getPeriodOf(int year, int weekOfYear, int weekCount, ITimeCalendar timeCalendar) {
    assert weekCount > 0;

    DateTime startWeek = Times.startTimeOfWeek(year, weekOfYear, timeCalendar);
    return new TimeRange(startWeek, startWeek.plusWeeks(weekCount));
}

From source file:kr.debop4j.timeperiod.tools.Times.java

License:Apache License

/**  ?  (weeks) ??  */
public static TimeRange getRelativeWeekPeriod(DateTime start, int weeks) {
    return getTimeRange(start, start.plusWeeks(weeks));
}

From source file:kr.debop4j.timeperiod.tools.Times.java

License:Apache License

/** ? ? (Week)  . */
public static List<ITimePeriod> foreachWeeks(ITimePeriod period) {
    assert period != null;
    if (isTraceEnabled)
        log.trace("[{}]?  (Week)  ...", period);

    List<ITimePeriod> weeks = Lists.newArrayList();
    if (period.isAnytime())
        return weeks;

    assertHasPeriod(period);/* ww w.  ja  v a 2 s  .  c  o m*/

    if (Times.isSameWeek(period.getStart(), period.getEnd())) {
        weeks.add(new TimeRange(period));
        return weeks;
    }

    DateTime current = period.getStart();
    DateTime weekEnd = Times.endTimeOfWeek(current);
    if (weekEnd.compareTo(period.getEnd()) >= 0) {
        weeks.add(new TimeRange(current, period.getEnd()));
        return weeks;
    }

    weeks.add(new TimeRange(current, weekEnd));
    current = weekEnd.plusWeeks(1);
    ITimeCalendar calendar = TimeCalendar.getDefault();

    while (current.compareTo(period.getEnd()) < 0) {
        weeks.add(Times.getWeekRange(current, calendar));
        current = current.plusWeeks(1);
    }

    current = Times.startTimeOfWeek(current);
    if (current.compareTo(period.getEnd()) < 0) {
        weeks.add(new TimeRange(current, period.getEnd()));
    }
    return weeks;
}

From source file:net.sourceforge.fenixedu.domain.student.WeeklyWorkLoad.java

License:Open Source License

public Interval getInterval() {
    final DateTime beginningOfSemester = new DateTime(getAttends().getBegginingOfLessonPeriod());
    final DateTime firstMonday = beginningOfSemester.withField(DateTimeFieldType.dayOfWeek(), 1);
    final DateTime start = firstMonday.withFieldAdded(DurationFieldType.weeks(), getWeekOffset().intValue());
    final DateTime end = start.plusWeeks(1);
    return new Interval(start, end);
}

From source file:net.tourbook.ui.views.calendar.CalendarGraph.java

License:Open Source License

private DateTime scrollBarEnd() {
    final DateTime dt = new DateTime().plusWeeks(_scrollBarShift);

    // ensure the date return is a "FirstDayOfTheWeek" !!!
    return dt.plusWeeks(1).withDayOfWeek(getFirstDayOfWeek());
}

From source file:net.tourbook.ui.views.calendar.CalendarGraph.java

License:Open Source License

private DateTime scrollBarStart() {
    // DateTime dt = _dataProvider.getFirstDateTime().plusWeeks(_scrollBarShift);
    DateTime dt = _dataProvider.getFirstDateTime();
    final DateTime now = new DateTime();
    final int weeks = (int) ((now.getMillis() - dt.getMillis()) / _WEEK_MILLIS);
    if (weeks < _MIN_SCROLLABLE_WEEKS) { // ensure the scrollable area has a reasonable size
        dt = now.minusWeeks(_MIN_SCROLLABLE_WEEKS);
    }/*from w w w .  j av  a2 s.c o  m*/
    dt = dt.plusWeeks(_scrollBarShift);
    // ensure the date return is a "FirstDayOfTheWeek" !!!
    return dt.minusWeeks(1).withDayOfWeek(getFirstDayOfWeek());
}

From source file:org.callistasoftware.netcare.model.entity.HealthPlanEntity.java

License:Open Source License

protected void calculateEnd() {
    if (durationUnit != null && startDate != null) {

        final DateTime dt = new DateTime(getStartDate());
        if (getDurationUnit().equals(DurationUnit.MONTH)) {
            setEndDate(dt.plusMonths(getDuration()).withTime(23, 59, 59, 999).toDate());
        } else {//  w  ww  .j av  a2  s.c  o  m
            setEndDate(dt.plusWeeks(getDuration()).withTime(23, 59, 59, 999).toDate());
        }
    } else {
        endDate = null;
    }
}