List of usage examples for org.joda.time LocalDate plusDays
public LocalDate plusDays(int days)
From source file:com.esofthead.mycollab.core.utils.BusinessDayTimeUtils.java
License:Open Source License
public static LocalDate plusDays(LocalDate refDate, int lagDate) { DateCalculator<LocalDate> calc1; boolean isForward = false; if (lagDate >= 0) { calc1 = LocalDateKitCalculatorsFactory.forwardCalculator("MyCollab"); isForward = true;/*w w w.j av a2 s . c om*/ } else { calc1 = LocalDateKitCalculatorsFactory.backwardCalculator("MyCollab"); } if (isForward) { refDate = refDate.minusDays(1); while (calc1.isNonWorkingDay(refDate)) { refDate = refDate.minusDays(1); } } else { refDate.plusDays(1); while (calc1.isNonWorkingDay(refDate)) { refDate = refDate.plusDays(1); } } calc1.setStartDate(refDate); calc1.moveByBusinessDays(lagDate); return calc1.getCurrentBusinessDate(); }
From source file:com.esofthead.mycollab.module.project.view.assignments.gantt.GanttItemWrapper.java
License:Open Source License
public void adjustTaskDatesByPredecessors(List<TaskPredecessor> predecessors) { if (CollectionUtils.isNotEmpty(predecessors)) { LocalDate currentStartDate = new LocalDate(getStartDate()); LocalDate currentEndDate = new LocalDate(getEndDate()); LocalDate boundStartDate = new LocalDate(1970, 1, 1); LocalDate boundEndDate = new LocalDate(2100, 1, 1); for (TaskPredecessor predecessor : predecessors) { int ganttIndex = predecessor.getGanttIndex(); GanttItemWrapper ganttPredecessor = gantt.getBeanContainer().getItemByGanttIndex(ganttIndex); int dur = getDuration().intValue() - 1; if (ganttPredecessor != null) { Integer lagDay = predecessor.getLagday() + 1; if (TaskPredecessor.FS.equals(predecessor.getPredestype())) { LocalDate endDate = new LocalDate(ganttPredecessor.getEndDate()); endDate = endDate.plusDays(1); LocalDate expectedStartDate = BusinessDayTimeUtils.plusDays(endDate, lagDay); if (boundStartDate.isBefore(expectedStartDate)) { boundStartDate = expectedStartDate; }//from w w w . j a v a2 s. c o m if (currentStartDate.isBefore(expectedStartDate)) { currentStartDate = expectedStartDate; LocalDate expectedEndDate = currentStartDate.plusDays(dur); currentEndDate = DateTimeUtils.min(boundEndDate, expectedEndDate); } } else if (TaskPredecessor.FF.equals(predecessor.getPredestype())) { LocalDate endDate = new LocalDate(ganttPredecessor.getEndDate()); LocalDate expectedEndDate = BusinessDayTimeUtils.plusDays(endDate, lagDay); if (boundEndDate.isAfter(expectedEndDate)) { boundEndDate = expectedEndDate; } if (currentEndDate.isAfter(expectedEndDate)) { currentEndDate = expectedEndDate; LocalDate expectedStartDate = currentEndDate.minusDays(dur); currentStartDate = DateTimeUtils.max(boundStartDate, expectedStartDate); } } else if (TaskPredecessor.SF.equals(predecessor.getPredestype())) { LocalDate startDate = new LocalDate(ganttPredecessor.getStartDate()); LocalDate expectedEndDate = BusinessDayTimeUtils.plusDays(startDate, lagDay); if (boundEndDate.isAfter(expectedEndDate)) { boundEndDate = expectedEndDate; } if (currentEndDate.isAfter(expectedEndDate)) { currentEndDate = expectedEndDate; LocalDate expectedStartDate = currentEndDate.minusDays(dur); currentStartDate = DateTimeUtils.max(boundStartDate, expectedStartDate); } } else if (TaskPredecessor.SS.equals(predecessor.getPredestype())) { LocalDate startDate = new LocalDate(ganttPredecessor.getStartDate()); LocalDate expectedStartDate = BusinessDayTimeUtils.plusDays(startDate, lagDay); if (boundStartDate.isBefore(expectedStartDate)) { boundStartDate = expectedStartDate; } if (currentStartDate.isBefore(expectedStartDate)) { currentStartDate = expectedStartDate; LocalDate expectedEndDate = BusinessDayTimeUtils.plusDays(startDate, dur); currentEndDate = DateTimeUtils.min(boundEndDate, expectedEndDate); } } else { throw new MyCollabException( "Do not support predecessor type " + predecessor.getPredestype()); } if (currentEndDate.isBefore(currentStartDate)) { throw new UserInvalidInputException("Invalid constraint"); } } } setStartAndEndDate(currentStartDate, currentEndDate, false, true); } }
From source file:com.esofthead.mycollab.module.project.view.user.ProjectUnresolvedAssignmentWidget.java
License:Open Source License
public void displayUnresolvedAssignmentsNextWeek() { title = AppContext.getMessage(ProjectI18nEnum.OPT_UNRESOLVED_ASSIGNMENT_NEXT_WEEK); searchCriteria = new ProjectGenericTaskSearchCriteria(); searchCriteria.setIsOpenned(new SearchField()); searchCriteria.setProjectIds(new SetSearchField<>(CurrentProjectVariables.getProjectId())); LocalDate now = new LocalDate(); now = now.plusDays(7); Date[] bounceDateOfWeek = DateTimeUtils.getBounceDatesOfWeek(now.toDate()); RangeDateSearchField range = new RangeDateSearchField(bounceDateOfWeek[0], bounceDateOfWeek[1]); searchCriteria.setDateInRange(range); updateSearchResult();/*from ww w . j av a2 s . c o m*/ }
From source file:com.esofthead.mycollab.module.project.view.user.UserUnresolvedAssignmentWidget.java
License:Open Source License
public void displayUnresolvedAssignmentsNextWeek() { title = AppContext.getMessage(ProjectI18nEnum.OPT_UNRESOLVED_ASSIGNMENT_NEXT_WEEK); searchCriteria = new ProjectGenericTaskSearchCriteria(); UserDashboardView userDashboardView = UIUtils.getRoot(this, UserDashboardView.class); searchCriteria.setIsOpenned(new SearchField()); searchCriteria.setProjectIds(new SetSearchField<>(userDashboardView.getInvolvedProjectKeys())); LocalDate now = new LocalDate(); now = now.plusDays(7); Date[] bounceDateOfWeek = DateTimeUtils.getBounceDatesOfWeek(now.toDate()); RangeDateSearchField range = new RangeDateSearchField(bounceDateOfWeek[0], bounceDateOfWeek[1]); searchCriteria.setDateInRange(range); updateSearchResult();/* w w w.ja va2 s . c o m*/ }
From source file:com.excilys.sugadroid.services.impl.ksoap2.AppointmentServicesKsoap2Impl.java
License:Open Source License
@Override public List<IAppointmentBean> getDayAppointments(LocalDate day) throws ServiceException { Log.d(TAG, "getDayAppointments called, date: " + day.toString()); checkLoggedIn();//from www.j a v a 2 s . co m boolean version4_5 = sessionBean.isVersion4_5(); SoapObject request = newEntryListRequest(); request.addProperty("module_name", "Meetings"); String query; query = "meetings.id = meetings_users.meeting_id AND meetings_users.user_id='" + sessionBean.getUserId() + "' AND "; if (version4_5) { query += "meetings.date_start='" + day.toString("yyyy-MM-dd") + "'"; } else { query += "meetings.date_start>='" + day.toString("yyyy-MM-dd") + "' AND meetings.date_start<'" + day.plusDays(1).toString("yyyy-MM-dd") + "'"; } request.addProperty("query", query); if (version4_5) { request.addProperty("order_by", "meetings.time_start asc"); } else { request.addProperty("order_by", "meetings.date_start asc"); } request.addProperty("offset", "0"); List<String> t = new Vector<String>(); t.add("id"); t.add("name"); request.addProperty("select_fields", t); request.addProperty("max_results", "100"); request.addProperty("deleted", "0"); List<IAppointmentBean> appointments = new ArrayList<IAppointmentBean>(); if (version4_5) { appointments.addAll(getEntryList(request, AppointmentBeanV4_5.class)); } else { appointments.addAll(getEntryList(request, AppointmentBeanV5.class)); } return appointments; }
From source file:com.excilys.sugadroid.services.impl.ksoap2.AppointmentServicesKsoap2Impl.java
License:Open Source License
@Override public Map<LocalDate, List<IAppointmentBean>> getAppointmentsInInterval(LocalDate start, LocalDate end) throws ServiceException { Log.d(TAG, "getAppointmentsInInterval called, days " + start.toString() + " " + end.toString()); checkLoggedIn();/* w ww . ja v a2s . c o m*/ if (start.compareTo(end) > 0) { throw new ServiceException("start day should be before or equal to end day"); } boolean version4_5 = sessionBean.isVersion4_5(); StringBuilder sb = new StringBuilder("meetings_users.meeting_id=meetings.id AND meetings_users.user_id='") .append(sessionBean.getUserId()).append("' AND "); if (version4_5) { sb.append("meetings.date_start>='").append(start.toString("yyyy-MM-dd")) .append("' AND meetings.date_start<'").append(end.plusDays(1).toString("yyyy-MM-dd")) .append("'"); } else { sb.append("meetings.date_start>='").append(start.toString("yyyy-MM-dd")) .append("' AND meetings.date_start<='").append(end.toString("yyyy-MM-dd")).append("'"); } String query = sb.toString(); SoapObject request = newEntryListRequest(); request.addProperty("module_name", "Meetings"); request.addProperty("query", query); if (version4_5) { request.addProperty("order_by", "meetings.date_start asc, meetings.time_start asc"); } else { request.addProperty("order_by", "meetings.date_start asc"); } request.addProperty("offset", "0"); List<String> t = new Vector<String>(); t.add("id"); t.add("name"); t.add("date_start"); if (version4_5) { t.add("time_start"); } request.addProperty("select_fields", t); request.addProperty("max_results", "1000"); request.addProperty("deleted", "0"); List<IAppointmentBean> appointments = new ArrayList<IAppointmentBean>(); if (version4_5) { appointments.addAll(getEntryList(request, AppointmentBeanV4_5.class)); } else { appointments.addAll(getEntryList(request, AppointmentBeanV5.class)); } Map<LocalDate, List<IAppointmentBean>> appointmentsInInterval = new HashMap<LocalDate, List<IAppointmentBean>>(); appointmentsInInterval.put(start, new ArrayList<IAppointmentBean>()); LocalDate day = start; while (!day.equals(end)) { day = day.plusDays(1); appointmentsInInterval.put(day, new ArrayList<IAppointmentBean>()); } for (IAppointmentBean appointment : appointments) { appointmentsInInterval.get(appointment.getDayStart()).add(appointment); } return appointmentsInInterval; }
From source file:com.excilys.sugadroid.tasks.GetInitialCalendarTask.java
License:Open Source License
@Override public void doRunAuthenticatedTask() throws ServiceException { Map<LocalDate, List<IAppointmentBean>> initialDaysAppointments; LocalDate today = new LocalDate(); LocalDate before = today.minusDays(appointmentsLoadingBefore); LocalDate after = today.plusDays(appointmentsLoadingAfter); initialDaysAppointments = appointmentServices.getAppointmentsInInterval(before, after); EagerLoadingCalendar calendar = new EagerLoadingCalendar(before, after, initialDaysAppointments); activity.onInitialCalendarLoaded(calendar); }
From source file:com.github.serddmitry.jodainterval.LocalDateIntervals.java
License:Apache License
/** An interval (from .. ) - equivalent to [from+1 .. ) */ public static LocalDateIntervalPartial sinceAndExcluding(LocalDate from) { checkNotNull(from, "lower bound of the interval cannot be null"); return new LocalDateIntervalWithLowerBound(from.plusDays(1)); }
From source file:com.gst.organisation.holiday.service.HolidayWritePlatformServiceJpaRepositoryImpl.java
License:Apache License
private void validateInputDates(final LocalDate fromDate, final LocalDate toDate, final LocalDate repaymentsRescheduledTo) { String defaultUserMessage = ""; if (toDate.isBefore(fromDate)) { defaultUserMessage = "To Date date cannot be before the From Date."; throw new HolidayDateException("to.date.cannot.be.before.from.date", defaultUserMessage, fromDate.toString(), toDate.toString()); }//from ww w .j av a 2 s . c o m if (repaymentsRescheduledTo.isEqual(fromDate) || repaymentsRescheduledTo.isEqual(toDate) || (repaymentsRescheduledTo.isAfter(fromDate) && repaymentsRescheduledTo.isBefore(toDate))) { defaultUserMessage = "Repayments rescheduled date should be before from date or after to date."; throw new HolidayDateException( "repayments.rescheduled.date.should.be.before.from.date.or.after.to.date", defaultUserMessage, repaymentsRescheduledTo.toString()); } final WorkingDays workingDays = this.daysRepositoryWrapper.findOne(); final Boolean isRepaymentOnWorkingDay = WorkingDaysUtil.isWorkingDay(workingDays, repaymentsRescheduledTo); if (!isRepaymentOnWorkingDay) { defaultUserMessage = "Repayments rescheduled date should not fall on non working days"; throw new HolidayDateException("repayments.rescheduled.date.should.not.fall.on.non.working.day", defaultUserMessage, repaymentsRescheduledTo.toString()); } // validate repaymentsRescheduledTo date // 1. should be within a 7 days date range. // 2. Alternative date should not be an exist holiday.//TBD // 3. Holiday should not be on an repaymentsRescheduledTo date of // another holiday.//TBD // restricting repaymentsRescheduledTo date to be within 7 days range // before or after from date and to date. if (repaymentsRescheduledTo.isBefore(fromDate.minusDays(7)) || repaymentsRescheduledTo.isAfter(toDate.plusDays(7))) { defaultUserMessage = "Repayments Rescheduled to date must be within 7 days before or after from and to dates"; throw new HolidayDateException("repayments.rescheduled.to.must.be.within.range", defaultUserMessage, fromDate.toString(), toDate.toString(), repaymentsRescheduledTo.toString()); } }
From source file:com.gst.organisation.workingdays.service.WorkingDaysUtil.java
License:Apache License
public static LocalDate getOffSetDateIfNonWorkingDay(final LocalDate date, final LocalDate nextMeetingDate, final WorkingDays workingDays) { // If date is not a non working day then return date. if (isWorkingDay(workingDays, date)) { return date; }//from w w w.j a v a 2 s .co m final RepaymentRescheduleType rescheduleType = RepaymentRescheduleType .fromInt(workingDays.getRepaymentReschedulingType()); switch (rescheduleType) { case INVALID: return date; case SAME_DAY: return date; case MOVE_TO_NEXT_WORKING_DAY: return getOffSetDateIfNonWorkingDay(date.plusDays(1), nextMeetingDate, workingDays); case MOVE_TO_NEXT_REPAYMENT_MEETING_DAY: return nextMeetingDate; case MOVE_TO_PREVIOUS_WORKING_DAY: return getOffSetDateIfNonWorkingDay(date.minusDays(1), nextMeetingDate, workingDays); default: return date; } }