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

The following examples show how to use org.joda.time.DateTime#withDayOfWeek() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
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
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 Project: liteflow   File: TuesdayCalculator.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public DateTime calculate(DateTime dateTime) {
    return dateTime.withDayOfWeek(2);
}
 
Example 4
Source Project: liteflow   File: MondayCalculator.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public DateTime calculate(DateTime dateTime) {
    return dateTime.withDayOfWeek(1);
}
 
Example 5
Source Project: liteflow   File: ThursdayCalculator.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public DateTime calculate(DateTime dateTime) {
    return dateTime.withDayOfWeek(4);
}
 
Example 6
Source Project: liteflow   File: WednesdayCalculator.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public DateTime calculate(DateTime dateTime) {
    return dateTime.withDayOfWeek(3);
}
 
Example 7
Source Project: liteflow   File: FridayCalculator.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public DateTime calculate(DateTime dateTime) {
    return dateTime.withDayOfWeek(5);
}
 
Example 8
Source Project: liteflow   File: SundayCalculator.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public DateTime calculate(DateTime dateTime) {
    return dateTime.withDayOfWeek(7);
}
 
Example 9
Source Project: liteflow   File: SaturdayCalculator.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public DateTime calculate(DateTime dateTime) {
    return dateTime.withDayOfWeek(6);
}
 
Example 10
Source Project: mojito   File: DropScheduleService.java    License: 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;
    }