Java Code Examples for org.joda.time.DateTime#withDayOfWeek()

The following examples show how to use org.joda.time.DateTime#withDayOfWeek() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WeeklyPeriodFilter.java    From dhis2-android-datacapture with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static DateTime fixEndDate(DateTime endDate) {
    if(endDate==null) {
        return null;
    }
    Calendar endDateCalendar = Calendar.getInstance();
    endDateCalendar.setTime(endDate.toDate());
    LocalDate fixedWeek = new LocalDate(endDate.withDayOfWeek(7));
    endDateCalendar.setTime(fixedWeek.toDate());
    return new DateTime(endDateCalendar.getTime());
}
 
Example 2
Source File: GanttDiagram.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void calculateFirstAndLastInstantInWeeklyMode(YearMonthDay begin) {
    if (begin == null) {
        throw new IllegalArgumentException();
    }
    DateTime beginDateTime = begin.toDateTimeAtMidnight();
    beginDateTime = (beginDateTime.getDayOfWeek() != 1) ? beginDateTime.withDayOfWeek(1) : beginDateTime;
    setFirstInstant(beginDateTime);
    setLastInstant(beginDateTime.plusDays(6));
}
 
Example 3
Source File: TuesdayCalculator.java    From liteflow with Apache License 2.0 4 votes vote down vote up
@Override
public DateTime calculate(DateTime dateTime) {
    return dateTime.withDayOfWeek(2);
}
 
Example 4
Source File: MondayCalculator.java    From liteflow with Apache License 2.0 4 votes vote down vote up
@Override
public DateTime calculate(DateTime dateTime) {
    return dateTime.withDayOfWeek(1);
}
 
Example 5
Source File: ThursdayCalculator.java    From liteflow with Apache License 2.0 4 votes vote down vote up
@Override
public DateTime calculate(DateTime dateTime) {
    return dateTime.withDayOfWeek(4);
}
 
Example 6
Source File: WednesdayCalculator.java    From liteflow with Apache License 2.0 4 votes vote down vote up
@Override
public DateTime calculate(DateTime dateTime) {
    return dateTime.withDayOfWeek(3);
}
 
Example 7
Source File: FridayCalculator.java    From liteflow with Apache License 2.0 4 votes vote down vote up
@Override
public DateTime calculate(DateTime dateTime) {
    return dateTime.withDayOfWeek(5);
}
 
Example 8
Source File: SundayCalculator.java    From liteflow with Apache License 2.0 4 votes vote down vote up
@Override
public DateTime calculate(DateTime dateTime) {
    return dateTime.withDayOfWeek(7);
}
 
Example 9
Source File: SaturdayCalculator.java    From liteflow with Apache License 2.0 4 votes vote down vote up
@Override
public DateTime calculate(DateTime dateTime) {
    return dateTime.withDayOfWeek(6);
}
 
Example 10
Source File: DropScheduleService.java    From mojito with Apache License 2.0 3 votes vote down vote up
DateTime getDropCreatedDate(DateTime dropDueDate) {

        DateTime dropCreatedDate = dropDueDate.withTime(dropScheduleConfig.getCreatedLocalTime());

        Integer dropDueDateDay = dropDueDate.getDayOfWeek();
        Integer dropStartDateDay = getDueDayToStartDay().get(dropDueDateDay);

        dropCreatedDate = dropCreatedDate.withDayOfWeek(dropStartDateDay);

        if (dropStartDateDay > dropDueDateDay) {
            dropCreatedDate = dropCreatedDate.minusWeeks(1);
        }

        return dropCreatedDate;
    }