List of usage examples for org.joda.time LocalDate plusDays
public LocalDate plusDays(int days)
From source file:me.vertretungsplan.parser.WebUntisParser.java
License:Mozilla Public License
/** * find out if there's a holiday currently and if so, also display substitutions after it * * @return/* w w w. j a v a2 s . c o m*/ * @throws JSONException * @throws CredentialInvalidException * @throws IOException */ private int getDaysToAdd() throws JSONException, CredentialInvalidException, IOException { final LocalDate today = LocalDate.now(); int daysToAdd = 0; try { // JSONArray holidays = getHolidays(); for (int i = 0; i < holidays.length(); i++) { LocalDate startDate = DATE_FORMAT .parseLocalDate(String.valueOf(holidays.getJSONObject(i).getInt("startDate"))); LocalDate endDate = DATE_FORMAT .parseLocalDate(String.valueOf(holidays.getJSONObject(i).getInt("endDate"))); if (!startDate.isAfter(today.plusDays(6)) && !endDate.isBefore(today)) { if (startDate.isBefore(today)) { daysToAdd += Days.daysBetween(today, endDate).getDays() + 1; } else { daysToAdd += Days.daysBetween(startDate, endDate).getDays() + 2; } } } } catch (UnauthorizedException ignored) { } return daysToAdd; }
From source file:module.organization.domain.Accountability.java
License:Open Source License
/** * /*from w ww .j a va 2s. com*/ * @param start start * @param end end * @return true if the given start and end date overlap in more than one day * with this accountability (exclusively, i.e. if the end date of * this accountability equals the begin date passed as argument, it * returns false) */ public boolean overlaps(final LocalDate start, final LocalDate end) { LocalDate startDateToUse = start == null ? start : start.plusDays(1); LocalDate endDateToUse = end == null ? end : end.minusDays(1); return intersects(startDateToUse, endDateToUse); }
From source file:net.objectlab.kit.datecalc.joda.LocalDateForwardHandler.java
License:Apache License
public LocalDate adjustDate(final LocalDate startDate, final int increment, final NonWorkingDayChecker<LocalDate> checker) { LocalDate date = startDate; while (checker.isNonWorkingDay(date)) { date = date.plusDays(increment); }/* ww w . j a v a 2 s .c o m*/ return date; }
From source file:net.objectlab.kit.datecalc.joda.LocalDateForwardUnlessNegativeHandler.java
License:Apache License
public LocalDate adjustDate(LocalDate startDate, int increment, NonWorkingDayChecker<LocalDate> checker) { LocalDate date = startDate; while (checker.isNonWorkingDay(date)) { if (increment < 0) { // act as a Backward calendar date = date.minusDays(1);/*from w w w. j a va2 s .c om*/ } else { // move forward by a day! date = date.plusDays(1); } } return date; }
From source file:net.objectlab.kit.datecalc.joda.LocalDateModifiedFollowingHandler.java
License:Apache License
public LocalDate adjustDate(LocalDate startDate, int increment, NonWorkingDayChecker<LocalDate> checker) { LocalDate date = startDate; final int month = date.getMonthOfYear(); int stepToUse = increment; while (checker.isNonWorkingDay(date)) { date = date.plusDays(stepToUse); if (date.getMonthOfYear() != month) { // flick to backward stepToUse *= -1;/* w w w .j a va2s.c o m*/ date = date.plusDays(stepToUse); } } return date; }
From source file:net.sourceforge.fenixedu.domain.accounting.installments.InstallmentForFirstTimeStudents.java
License:Open Source License
@Override public LocalDate getEndDate(final Event event) { final GratuityEvent gratuityEvent = (GratuityEvent) event; final LocalDate startDate = gratuityEvent.getRegistration().getStartDate().toLocalDate(); return startDate.plusDays(getNumberOfDaysToStartApplyingPenalty()); }
From source file:net.sourceforge.fenixedu.domain.personnelSection.contracts.PersonProfessionalData.java
License:Open Source License
public ProfessionalCategory getLastProfessionalCategoryByCategoryType(CategoryType categoryType, LocalDate beginDate, LocalDate endDate) { Interval dateInterval = null;//w w w. ja va 2 s . c o m if (beginDate != null && endDate != null) { dateInterval = new Interval(beginDate.toDateTimeAtStartOfDay(), endDate.plusDays(1).toDateTimeAtStartOfDay()); } PersonContractSituation lastPersonContractSituation = null; GiafProfessionalData giafProfessionalData = getGiafProfessionalData(); if (giafProfessionalData != null) { for (final PersonContractSituation situation : giafProfessionalData .getValidPersonContractSituations()) { if ((dateInterval == null || situation.overlaps(dateInterval)) && (categoryType == null || (situation.getProfessionalCategory() != null && situation.getProfessionalCategory().getCategoryType().equals(categoryType))) && (lastPersonContractSituation == null || situation.isAfter(lastPersonContractSituation))) { lastPersonContractSituation = situation; } } } return lastPersonContractSituation == null ? null : lastPersonContractSituation.getProfessionalCategory(); }
From source file:net.sourceforge.fenixedu.domain.personnelSection.contracts.PersonProfessionalData.java
License:Open Source License
public PersonContractSituation getCurrentOrLastPersonContractSituationByCategoryType(CategoryType categoryType, LocalDate beginDate, LocalDate endDate) { LocalDate today = new LocalDate(); Interval dateInterval = null;//from w w w.j a v a 2s. c o m if (beginDate != null && endDate != null) { dateInterval = new Interval(beginDate.toDateTimeAtStartOfDay(), endDate.plusDays(1).toDateTimeAtStartOfDay()); } PersonContractSituation lastPersonContractSituation = null; PersonContractSituation currentPersonContractSituation = null; GiafProfessionalData giafProfessionalDataByCategoryType = getGiafProfessionalData(); if (giafProfessionalDataByCategoryType != null) { for (final PersonContractSituation situation : giafProfessionalDataByCategoryType .getValidPersonContractSituations()) { if ((categoryType == null || (situation.getProfessionalCategory() != null && situation.getProfessionalCategory().getCategoryType().equals(categoryType)))) { if ((dateInterval == null || situation.overlaps(dateInterval))) { if (situation.isActive(today) && (currentPersonContractSituation == null || situation.isAfter(currentPersonContractSituation))) { currentPersonContractSituation = situation; } lastPersonContractSituation = situation; } } } } return currentPersonContractSituation != null ? currentPersonContractSituation : lastPersonContractSituation; }
From source file:net.sourceforge.fenixedu.domain.phd.PhdProgramCalendarUtil.java
License:Open Source License
static public int countWorkDaysBetween(final LocalDate startDate, final LocalDate endDate) { int result = 0; LocalDate current = startDate.plusDays(1); while (!current.isAfter(endDate)) { if (isWorkDay(current)) { result++;/* w w w . j a v a2 s .c o m*/ } current = current.plusDays(1); } return result; }
From source file:net.sourceforge.fenixedu.domain.phd.PhdProgramCalendarUtil.java
License:Open Source License
static public LocalDate addWorkDaysTo(final LocalDate date, final int workDays) { int current = workDays; LocalDate result = date; while (current > 0) { result = result.plusDays(1); if (isWorkDay(result)) { current--;// w ww .ja va 2 s . c om } } return result; }