List of usage examples for org.joda.time LocalDate plusWeeks
public LocalDate plusWeeks(int weeks)
From source file:com.axelor.apps.base.service.scheduler.SchedulerService.java
License:Open Source License
/** * Mthode qui dtermine la prochaine date d'xcution d'un planificateur pour un rythme hebdomadaire * * @param scheduler/*from w ww. j a va 2 s. co m*/ * Instance de planificateur * @param date * Derniere date d'xcution thorique * * @return LocalDate * Prochaine date d'xcution */ private LocalDate getWeeklyComputeDate(Scheduler scheduler, LocalDate date) { int weekDay = 0; if (scheduler.getMonday()) weekDay = DateTimeConstants.MONDAY; else if (scheduler.getTuesday()) weekDay = DateTimeConstants.TUESDAY; else if (scheduler.getWednesday()) weekDay = DateTimeConstants.WEDNESDAY; else if (scheduler.getThursday()) weekDay = DateTimeConstants.THURSDAY; else if (scheduler.getFriday()) weekDay = DateTimeConstants.FRIDAY; else if (scheduler.getSaturday()) weekDay = DateTimeConstants.SATURDAY; else if (scheduler.getSunday()) weekDay = DateTimeConstants.SUNDAY; if (weekDay == 0) weekDay = 1; return date.plusWeeks(scheduler.getWeekWeekly()).withDayOfWeek(weekDay); }
From source file:com.axelor.apps.base.service.scheduler.SchedulerService.java
License:Open Source License
/** * Mthode qui dtermine la prochaine date d'xcution d'un planificateur pour un rythme mensuel * * @param scheduler//from ww w . j a v a2s. c om * Instance de planificateur * @param date * Derniere date d'xcution thorique * * @return LocalDate * Prochaine date d'xcution */ private LocalDate getMonthlyComputeDate(Scheduler scheduler, LocalDate date) { if (scheduler.getDayMonthly() == 0) return date.plusMonths(scheduler.getMonthMonthly()).withDayOfMonth(1); else { int start = date.plusWeeks(scheduler.getWeekWeekly()).dayOfMonth().getMinimumValue(); int end = date.plusWeeks(scheduler.getWeekWeekly()).dayOfMonth().getMaximumValue(); if (start <= scheduler.getDayMonthly() && scheduler.getDayMonthly() <= end) return date.plusMonths(scheduler.getMonthMonthly()).withDayOfMonth(scheduler.getDayMonthly()); else if (scheduler.getDayMonthly() < start) return date.plusWeeks(scheduler.getWeekWeekly()).dayOfMonth().withMinimumValue(); else if (scheduler.getDayMonthly() > end) return date.plusWeeks(scheduler.getWeekWeekly()).dayOfMonth().withMaximumValue(); return null; } }
From source file:com.axelor.apps.base.service.scheduler.SchedulerService.java
License:Open Source License
/** * Mthode qui dtermine la prochaine date d'xcution d'un planificateur pour un rythme annuel * * @param scheduler/*w w w.ja va 2s. c om*/ * Instance de planificateur * @param date * Derniere date d'xcution thorique * * @return LocalDate * Prochaine date d'xcution */ private LocalDate getAnnualComputeDate(Scheduler scheduler, LocalDate date) { int monthOfYear = 0; if (scheduler.getMonthAnnuallySelect().equals(IAdministration.JAN)) monthOfYear = DateTimeConstants.JANUARY; else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.FEB)) monthOfYear = DateTimeConstants.FEBRUARY; else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.MAR)) monthOfYear = DateTimeConstants.MARCH; else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.APR)) monthOfYear = DateTimeConstants.APRIL; else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.MAY)) monthOfYear = DateTimeConstants.MAY; else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.JUN)) monthOfYear = DateTimeConstants.JUNE; else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.JUL)) monthOfYear = DateTimeConstants.JULY; else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.AUG)) monthOfYear = DateTimeConstants.AUGUST; else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.SEP)) monthOfYear = DateTimeConstants.SEPTEMBER; else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.OCT)) monthOfYear = DateTimeConstants.OCTOBER; else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.NOV)) monthOfYear = DateTimeConstants.NOVEMBER; else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.DEC)) monthOfYear = DateTimeConstants.DECEMBER; if (monthOfYear != 0) { int start = date.plusWeeks(scheduler.getWeekWeekly()).dayOfMonth().getMinimumValue(); int end = date.plusWeeks(scheduler.getWeekWeekly()).dayOfMonth().getMaximumValue(); if (start <= scheduler.getDayAnnually() && scheduler.getDayAnnually() <= end) return date.plusYears(scheduler.getYearAnnually()).withMonthOfYear(monthOfYear) .withDayOfMonth(scheduler.getDayAnnually()); else if (scheduler.getDayMonthly() < start) return date.plusYears(scheduler.getYearAnnually()).withMonthOfYear(monthOfYear).dayOfMonth() .withMinimumValue(); else if (scheduler.getDayMonthly() > end) return date.plusYears(scheduler.getYearAnnually()).withMonthOfYear(monthOfYear).dayOfMonth() .withMaximumValue(); } return null; }
From source file:com.axelor.apps.crm.service.TargetService.java
License:Open Source License
public LocalDate getNextDate(int periodTypeSelect, LocalDate date) { switch (periodTypeSelect) { case ITarget.NONE: return date; case ITarget.MONTHLY: return date.plusMonths(1); case ITarget.WEEKLY: return date.plusWeeks(1); case ITarget.DAILY: return date.plusDays(1); default:/*ww w . j a v a2 s . c o m*/ return date; } }
From source file:com.gst.portfolio.calendar.service.CalendarUtils.java
License:Apache License
public static LocalDate getRecentEligibleMeetingDate(final String recurringRule, final LocalDate seedDate, final boolean isSkipMeetingOnFirstDay, final Integer numberOfDays) { LocalDate currentDate = DateUtils.getLocalDateOfTenant(); final Recur recur = CalendarUtils.getICalRecur(recurringRule); if (recur == null) { return null; }/*from ww w . j av a 2 s.co m*/ if (isValidRecurringDate(recur, seedDate, currentDate, isSkipMeetingOnFirstDay, numberOfDays)) { return currentDate; } if (recur.getFrequency().equals(Recur.DAILY)) { currentDate = currentDate.plusDays(recur.getInterval()); } else if (recur.getFrequency().equals(Recur.WEEKLY)) { currentDate = currentDate.plusWeeks(recur.getInterval()); } else if (recur.getFrequency().equals(Recur.MONTHLY)) { currentDate = currentDate.plusMonths(recur.getInterval()); } else if (recur.getFrequency().equals(Recur.YEARLY)) { currentDate = currentDate.plusYears(recur.getInterval()); } return getNextRecurringDate(recur, seedDate, currentDate); }
From source file:com.gst.portfolio.loanaccount.domain.Loan.java
License:Apache License
private LocalDate getMaxDateLimitForNewRepayment(final PeriodFrequencyType periodFrequencyType, final Integer loanRepaymentInterval, final LocalDate startDate) { LocalDate dueRepaymentPeriodDate = startDate; final Integer repaidEvery = 2 * loanRepaymentInterval; switch (periodFrequencyType) { case DAYS:// ww w .j av a 2 s.c o m dueRepaymentPeriodDate = startDate.plusDays(repaidEvery); break; case WEEKS: dueRepaymentPeriodDate = startDate.plusWeeks(repaidEvery); break; case MONTHS: dueRepaymentPeriodDate = startDate.plusMonths(repaidEvery); break; case YEARS: dueRepaymentPeriodDate = startDate.plusYears(repaidEvery); break; case INVALID: break; } return dueRepaymentPeriodDate.minusDays(1);// get 2n-1 range date from // startDate }
From source file:com.gst.portfolio.loanaccount.loanschedule.domain.DefaultScheduledDateGenerator.java
License:Apache License
@Override public LocalDate getRepaymentPeriodDate(final PeriodFrequencyType frequency, final int repaidEvery, final LocalDate startDate, Integer nthDay, DayOfWeekType dayOfWeek) { LocalDate dueRepaymentPeriodDate = startDate; switch (frequency) { case DAYS://w w w. j a v a 2s . c o m dueRepaymentPeriodDate = startDate.plusDays(repaidEvery); break; case WEEKS: dueRepaymentPeriodDate = startDate.plusWeeks(repaidEvery); break; case MONTHS: dueRepaymentPeriodDate = startDate.plusMonths(repaidEvery); if (!(nthDay == null || dayOfWeek == null || dayOfWeek == DayOfWeekType.INVALID)) { dueRepaymentPeriodDate = adjustToNthWeekDay(dueRepaymentPeriodDate, nthDay, dayOfWeek.getValue()); } break; case YEARS: dueRepaymentPeriodDate = startDate.plusYears(repaidEvery); break; case INVALID: break; } return dueRepaymentPeriodDate; }
From source file:com.gst.portfolio.loanaccount.loanschedule.domain.DefaultScheduledDateGenerator.java
License:Apache License
private LocalDate adjustToNthWeekDay(LocalDate dueRepaymentPeriodDate, int nthDay, int dayOfWeek) { // adjust date to start of month dueRepaymentPeriodDate = dueRepaymentPeriodDate.withDayOfMonth(1); // adjust date to next week if current day is past specified day of // week./* w w w .j av a 2 s .com*/ if (dueRepaymentPeriodDate.getDayOfWeek() > dayOfWeek) { dueRepaymentPeriodDate = dueRepaymentPeriodDate.plusWeeks(1); } // adjust date to specified date of week dueRepaymentPeriodDate = dueRepaymentPeriodDate.withDayOfWeek(dayOfWeek); // adjust to specified nth week day dueRepaymentPeriodDate = dueRepaymentPeriodDate.plusWeeks(nthDay - 1); return dueRepaymentPeriodDate; }
From source file:com.gst.portfolio.loanaccount.loanschedule.domain.DefaultScheduledDateGenerator.java
License:Apache License
@Override public Boolean isDateFallsInSchedule(final PeriodFrequencyType frequency, final int repaidEvery, final LocalDate startDate, final LocalDate date) { boolean isScheduledDate = false; switch (frequency) { case DAYS:// www .j a va2 s .co m int diff = Days.daysBetween(startDate, date).getDays(); isScheduledDate = (diff % repaidEvery) == 0; break; case WEEKS: int weekDiff = Weeks.weeksBetween(startDate, date).getWeeks(); isScheduledDate = (weekDiff % repaidEvery) == 0; if (isScheduledDate) { LocalDate modifiedDate = startDate.plusWeeks(weekDiff); isScheduledDate = modifiedDate.isEqual(date); } break; case MONTHS: int monthDiff = Months.monthsBetween(startDate, date).getMonths(); isScheduledDate = (monthDiff % repaidEvery) == 0; if (isScheduledDate) { LocalDate modifiedDate = startDate.plusMonths(monthDiff); isScheduledDate = modifiedDate.isEqual(date); } break; case YEARS: int yearDiff = Years.yearsBetween(startDate, date).getYears(); isScheduledDate = (yearDiff % repaidEvery) == 0; if (isScheduledDate) { LocalDate modifiedDate = startDate.plusYears(yearDiff); isScheduledDate = modifiedDate.isEqual(date); } break; case INVALID: break; } return isScheduledDate; }
From source file:com.gst.portfolio.loanaccount.loanschedule.domain.LoanApplicationTerms.java
License:Apache License
private LocalDate getPeriodEndDate(final LocalDate startDate) { LocalDate dueRepaymentPeriodDate = startDate; switch (this.repaymentPeriodFrequencyType) { case DAYS:/*from w w w .j ava 2 s .c o m*/ dueRepaymentPeriodDate = startDate.plusDays(this.repaymentEvery); break; case WEEKS: dueRepaymentPeriodDate = startDate.plusWeeks(this.repaymentEvery); break; case MONTHS: dueRepaymentPeriodDate = startDate.plusMonths(this.repaymentEvery); break; case YEARS: dueRepaymentPeriodDate = startDate.plusYears(this.repaymentEvery); break; case INVALID: break; } return dueRepaymentPeriodDate; }