Example usage for org.joda.time LocalDate plusDays

List of usage examples for org.joda.time LocalDate plusDays

Introduction

In this page you can find the example usage for org.joda.time LocalDate plusDays.

Prototype

public LocalDate plusDays(int days) 

Source Link

Document

Returns a copy of this date plus the specified number of days.

Usage

From source file:com.metinkale.prayerapp.vakit.times.Times.java

License:Apache License

@NonNull
private LocalDateTime getTimeCal(@Nullable LocalDate date, int time) {
    if (date == null) {
        date = LocalDate.now();/*from  w  w w  .j a v  a 2  s.  co  m*/
    }
    if ((time < 0) || (time > 5)) {
        while (time >= 6) {
            date = date.plusDays(1);
            time -= 6;
        }

        while (time <= -1) {
            date = date.minusDays(1);
            time += 6;
        }
    }

    LocalDateTime timeCal = date.toLocalDateTime(new LocalTime(getTime(date, time)));
    int h = timeCal.getHourOfDay();
    if ((time >= 3) && (h < 5)) {
        timeCal = timeCal.plusDays(1);
    }
    return timeCal;
}

From source file:com.metinkale.prayerapp.vakit.times.Times.java

License:Apache License

public String getTime(@Nullable LocalDate date, int time) {
    if (date == null) {
        date = LocalDate.now();/*from  ww  w.  ja  va  2s  .c  o m*/
    }
    if ((time < 0) || (time > 5)) {
        while (time >= 6) {
            date = date.plusDays(1);
            time -= 6;
        }

        while (time == -1) {
            date = date.minusDays(1);
            time += 6;
        }

    }
    return adj(_getTime(date, time), time);
}

From source file:com.metinkale.prayerapp.vakit.times.WebTimes.java

License:Apache License

private int getSyncedDays() {
    LocalDate date = LocalDate.now().plusDays(1);
    int i = 0;//from w  ww.j a va  2 s.co  m
    while (i < 45) {
        String prefix = date.toString("yyyy-MM-dd") + "-";
        String times[] = { this.times.get(prefix + 0), this.times.get(prefix + 1), this.times.get(prefix + 2),
                this.times.get(prefix + 3), this.times.get(prefix + 4), this.times.get(prefix + 5) };
        for (String time : times) {
            if (time == null || time.contains("00:00"))
                return i;
        }
        i++;
        date = date.plusDays(1);
    }
    return i;

}

From source file:com.metinkale.prayerapp.vakit.times.WebTimes.java

License:Apache License

@NonNull
public LocalDate getFirstSyncedDay() {
    LocalDate date = LocalDate.now();
    int i = 0;/*from   ww w .  ja v a2  s. co  m*/
    while (true) {
        String prefix = date.toString("yyyy-MM-dd") + "-";
        String times[] = { this.times.get(prefix + 0), this.times.get(prefix + 1), this.times.get(prefix + 2),
                this.times.get(prefix + 3), this.times.get(prefix + 4), this.times.get(prefix + 5) };
        for (String time : times) {
            if (time == null || time.contains("00:00") || i > this.times.size())
                return date.plusDays(1);
        }
        i++;
        date = date.minusDays(1);
    }
}

From source file:com.metinkale.prayerapp.vakit.times.WebTimes.java

License:Apache License

@NonNull
public LocalDate getLastSyncedDay() {
    LocalDate date = LocalDate.now();
    int i = 0;/*from w w w  .ja  v a  2  s.  c  o m*/
    while (true) {
        String prefix = date.toString("yyyy-MM-dd") + "-";
        String times[] = { this.times.get(prefix + 0), this.times.get(prefix + 1), this.times.get(prefix + 2),
                this.times.get(prefix + 3), this.times.get(prefix + 4), this.times.get(prefix + 5) };
        for (String time : times) {
            if (time == null || time.contains("00:00") || i > this.times.size())
                return date.minusDays(1);
        }
        i++;
        date = date.plusDays(1);
    }
}

From source file:com.mycollab.module.project.view.user.ProjectUnresolvedTicketsWidget.java

License:Open Source License

public void displayUnresolvedAssignmentsNextWeek() {
    title = UserUIContext.getMessage(ProjectI18nEnum.OPT_UNRESOLVED_TICKET_NEXT_WEEK);
    searchCriteria = new ProjectTicketSearchCriteria();
    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   w  ww .j  a v  a 2 s  .  c  om
}

From source file:com.mycollab.module.project.view.user.UserUnresolvedAssignmentWidget.java

License:Open Source License

public void displayUnresolvedAssignmentsNextWeek() {
    title = UserUIContext.getMessage(ProjectI18nEnum.OPT_UNRESOLVED_TICKET_NEXT_WEEK);
    searchCriteria = new ProjectTicketSearchCriteria();
    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  .  java  2s  .  c  o m*/
}

From source file:com.ning.billing.invoice.tests.inAdvance.GenericProRationTestBase.java

License:Apache License

@Test(groups = "fast")
public void testSinglePlan_CrossingYearBoundary() throws InvalidDateSequenceException {
    final LocalDate startDate = invoiceUtil.buildDate(2011, 12, 15);
    final LocalDate oneCycleLater = startDate.plusMonths(getBillingPeriod().getNumberOfMonths());

    // test just before the billing cycle day
    testCalculateNumberOfBillingCycles(startDate, oneCycleLater.plusDays(-1), 15, ONE);

    // test on the billing cycle day
    testCalculateNumberOfBillingCycles(startDate, oneCycleLater, 15, TWO);

    // test just after the billing cycle day
    testCalculateNumberOfBillingCycles(startDate, oneCycleLater.plusDays(1), 15, TWO);
}

From source file:com.ning.billing.invoice.tests.inAdvance.GenericProRationTestBase.java

License:Apache License

@Test(groups = "fast")
public void testSinglePlan_MovingForwardThroughTime() throws InvalidDateSequenceException {
    final LocalDate startDate = invoiceUtil.buildDate(2011, 1, 31);
    BigDecimal expectedValue = ONE;

    for (int i = 1; i <= 12; i++) {
        final LocalDate oneCycleLater = startDate.plusMonths(i * getBillingPeriod().getNumberOfMonths());
        // test just before the billing cycle day
        testCalculateNumberOfBillingCycles(startDate, oneCycleLater.plusDays(-1), 31, expectedValue);

        expectedValue = expectedValue.add(ONE);

        // test on the billing cycle day
        testCalculateNumberOfBillingCycles(startDate, oneCycleLater, 31, expectedValue);

        // test just after the billing cycle day
        testCalculateNumberOfBillingCycles(startDate, oneCycleLater.plusDays(1), 31, expectedValue);
    }/*from  w ww.  j a  v  a 2s .  com*/
}

From source file:com.phloc.datetime.PDTUtils.java

License:Apache License

/**
 * Count all non-weekend days in the range. Does not consider holidays!
 *
 * @param aStartDate/*from www  .jav a  2 s  .  c  o  m*/
 *        start date
 * @param aEndDate
 *        end date
 * @return days not counting Saturdays and Sundays. If start date is after end
 *         date, the value will be negative! If start date equals end date the
 *         return will be 1 if it is a week day.
 */
public static int getWeekDays(@Nonnull final LocalDate aStartDate, @Nonnull final LocalDate aEndDate) {
    ValueEnforcer.notNull(aStartDate, "StartDate");
    ValueEnforcer.notNull(aEndDate, "EndDate");

    final boolean bFlip = aStartDate.isAfter(aEndDate);
    LocalDate aCurDate = bFlip ? aEndDate : aStartDate;
    final LocalDate aRealEndDate = bFlip ? aStartDate : aEndDate;

    int ret = 0;
    while (!aRealEndDate.isBefore(aCurDate)) {
        if (!isWeekend(aCurDate))
            ret++;
        aCurDate = aCurDate.plusDays(1);
    }
    return bFlip ? -1 * ret : ret;
}