Example usage for org.joda.time DateTime withWeekOfWeekyear

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

Introduction

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

Prototype

public DateTime withWeekOfWeekyear(int weekOfWeekyear) 

Source Link

Document

Returns a copy of this datetime with the week of weekyear field updated.

Usage

From source file:org.kuali.kpme.tklm.leave.accrual.service.AccrualServiceImpl.java

License:Educational Community License

@Override
public DateTime getNextAccrualIntervalDate(String earnInterval, DateTime aDate) {
    DateTime nextAccrualIntervalDate = null;

    if (earnInterval.equals(HrConstants.ACCRUAL_EARN_INTERVAL_CODE.DAILY)) {
        nextAccrualIntervalDate = aDate;
    } else if (earnInterval.equals(HrConstants.ACCRUAL_EARN_INTERVAL_CODE.WEEKLY)) {
        if (aDate.getDayOfWeek() != DateTimeConstants.SATURDAY) {
            nextAccrualIntervalDate = aDate.withDayOfWeek(DateTimeConstants.SATURDAY);
        } else {//from   ww  w .  j  ava 2 s .c  om
            nextAccrualIntervalDate = aDate.withWeekOfWeekyear(1);
        }
    } else if (earnInterval.equals(HrConstants.ACCRUAL_EARN_INTERVAL_CODE.SEMI_MONTHLY)) {
        if (aDate.getDayOfMonth() <= 15) {
            nextAccrualIntervalDate = aDate.withDayOfMonth(15);
        } else {
            nextAccrualIntervalDate = aDate.withDayOfMonth(aDate.dayOfMonth().getMaximumValue());
        }
    } else if (earnInterval.equals(HrConstants.ACCRUAL_EARN_INTERVAL_CODE.MONTHLY)) {
        nextAccrualIntervalDate = aDate.withDayOfMonth(aDate.dayOfMonth().getMaximumValue());
    } else if (earnInterval.equals(HrConstants.ACCRUAL_EARN_INTERVAL_CODE.YEARLY)) {
        nextAccrualIntervalDate = aDate.withDayOfYear(aDate.dayOfYear().getMaximumValue());
    } else if (earnInterval.equals(HrConstants.ACCRUAL_EARN_INTERVAL_CODE.NO_ACCRUAL)) {
        nextAccrualIntervalDate = aDate;
    }

    return nextAccrualIntervalDate;
}