Java Code Examples for org.joda.time.LocalDate#plusDays()

The following examples show how to use org.joda.time.LocalDate#plusDays() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EthController.java    From etherscan-explorer with GNU General Public License v3.0 6 votes vote down vote up
@RequestMapping("/tx/cnt_static")
public ResponseVo<Map<String, Long>> transactionStatic() {
    Date from = LocalDate.now().plusDays(-15).toDate();
    Date to = LocalDate.now().toDate();
    List<DayCount> dayCounts = ethService.countTransactionByTimestamp(from, to);
    Map<String, Long> dayCountMap = dayCounts.stream()
        .collect(Collectors.toMap(DayCount::getDay, DayCount::getCount));

    LocalDate fromLocalDate = LocalDate.fromDateFields(from);
    LocalDate toLocalDate = LocalDate.fromDateFields(to);
    while (fromLocalDate.isBefore(toLocalDate)) {
        dayCountMap.putIfAbsent(DateUtils.toDay(fromLocalDate.toDate()), 0L);
        fromLocalDate = fromLocalDate.plusDays(1);
    }

    ResponseVo<Map<String, Long>> result = new ResponseVo<>();
    result.setData(new TreeMap<>(dayCountMap));

    return result;
}
 
Example 2
Source File: CalendarUtil.java    From NCalendar with Apache License 2.0 6 votes vote down vote up
/**
 * 周视图的数据
 *
 * @param localDate
 * @return
 */
public static List<LocalDate> getWeekCalendar(LocalDate localDate, int type) {
    List<LocalDate> dateList = new ArrayList<>();

    if (type == Attrs.MONDAY) {
        localDate = getMonFirstDayOfWeek(localDate);
    } else {
        localDate = getSunFirstDayOfWeek(localDate);
    }

    for (int i = 0; i < 7; i++) {
        LocalDate date = localDate.plusDays(i);
        dateList.add(date);
    }
    return dateList;
}
 
Example 3
Source File: WebTimes.java    From prayer-times-android with Apache License 2.0 6 votes vote down vote up
private int getSyncedDays() {
    LocalDate date = LocalDate.now().plusDays(1);
    int i = 0;
    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;

}
 
Example 4
Source File: Times.java    From prayer-times-android with Apache License 2.0 6 votes vote down vote up
@NonNull
public LocalDateTime getTime(@NonNull LocalDate date, int time) {
    while (time < 0) {
        date = date.minusDays(1);
        time += Vakit.LENGTH;
    }

    while (time >= Vakit.LENGTH) {
        date = date.plusDays(1);
        time -= Vakit.LENGTH;
    }
    LocalDateTime dt = parseTime(date, getStrTime(date, Vakit.getByIndex(time))).plusMinutes(getMinuteAdj()[time]);


    int h = dt.getHourOfDay();
    if ((time >= Vakit.DHUHR.ordinal()) && (h < 5)) {
        dt = dt.plusDays(1);
    }
    return dt;
}
 
Example 5
Source File: JodaWorkingWeekTest.java    From objectlabkit with Apache License 2.0 6 votes vote down vote up
public void testIsWorkingDay() {
    LocalDate date = new LocalDate("2006-08-01");
    Assert.assertTrue("Calendar.TUESDAY", ww.isWorkingDay(date));
    date = date.plusDays(1);
    Assert.assertTrue("Calendar.WEDNESDAY", ww.isWorkingDay(date));
    date = date.plusDays(1);
    Assert.assertTrue("Calendar.THURSDAY", ww.isWorkingDay(date));
    date = date.plusDays(1);
    Assert.assertTrue("Calendar.FRIDAY", ww.isWorkingDay(date));
    date = date.plusDays(1);
    Assert.assertFalse("Calendar.SATURDAY", ww.isWorkingDay(date));
    date = date.plusDays(1);
    Assert.assertFalse("Calendar.SUNDAY", ww.isWorkingDay(date));
    date = date.plusDays(1);
    Assert.assertTrue("Calendar.MONDAY", ww.isWorkingDay(date));
}
 
Example 6
Source File: WebTimes.java    From prayer-times-android with Apache License 2.0 6 votes vote down vote up
private int getSyncedDays() {
    LocalDate date = LocalDate.now().plusDays(1);
    int i = 0;
    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;

}
 
Example 7
Source File: WebTimes.java    From prayer-times-android with Apache License 2.0 6 votes vote down vote up
@NonNull
public LocalDate getFirstSyncedDay() {
    LocalDate date = LocalDate.now();
    int i = 0;
    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);
    }
}
 
Example 8
Source File: Times.java    From prayer-times-android with Apache License 2.0 6 votes vote down vote up
@NonNull
public LocalDateTime getTime(@NonNull LocalDate date, int time) {
    while (time < 0) {
        date = date.minusDays(1);
        time += Vakit.LENGTH;
    }

    while (time >= Vakit.LENGTH) {
        date = date.plusDays(1);
        time -= Vakit.LENGTH;
    }
    LocalDateTime dt = parseTime(date, getStrTime(date, Vakit.getByIndex(time))).plusMinutes(getMinuteAdj()[time]);


    int h = dt.getHourOfDay();
    if ((time >= Vakit.DHUHR.ordinal()) && (h < 5)) {
        dt = dt.plusDays(1);
    }
    return dt;
}
 
Example 9
Source File: LocalDateForwardUnlessNegativeHandler.java    From objectlabkit with Apache License 2.0 5 votes vote down vote up
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);
        } else {
            // move forward by a day!
            date = date.plusDays(1);
        }
    }
    return date;
}
 
Example 10
Source File: WeeklyExpiryDayValidator.java    From dhis2-android-datacapture with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected LocalDate getMaxDateCanEdit() {
    LocalDate periodDate = LocalDate.parse(period, DateTimeFormat.forPattern(getDateFormat()));
    periodDate = periodDate.withDayOfWeek(weekStarts());
    periodDate = periodDate.plusDays(6);
    return periodDate.plusDays(expiryDays - 1);
}
 
Example 11
Source File: FinancialYearJulyExpiryDayValidator.java    From dhis2-android-datacapture with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected LocalDate getMaxDateCanEdit() {
    LocalDate periodDate = LocalDate.parse(period,
            DateTimeFormat.forPattern(DATE_FORMAT));
    periodDate = periodDate.withMonthOfYear(monthOfYear());
    periodDate = periodDate.plusMonths(plusMonths());
    return periodDate.plusDays(expiryDays - 2);
}
 
Example 12
Source File: DayIterator.java    From dhis2-android-datacapture with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public DayIterator(int openFPs, String[] dataInputPeriods) {
    super(dataInputPeriods);
    openFuturePeriods = openFPs;
    cPeriod = new LocalDate(currentDate.getYear(), JAN, 1);
    checkDate = new LocalDate(cPeriod);
    maxDate = new LocalDate(currentDate.getYear(), currentDate.getMonthOfYear(), currentDate.getDayOfMonth());
    for (int i = 0; i <= openFuturePeriods-1; i++) {
        maxDate = maxDate.plusDays(1);
    }
}
 
Example 13
Source File: OrderMenu.java    From estatio with Apache License 2.0 5 votes vote down vote up
OrderMenu.OrderFinder filterOrFindByOrderDate(final LocalDate orderDate) {
    if (orderDate == null)
        return this;
    LocalDate orderDateStart = orderDate.minusDays(5);
    LocalDate orderDateEnd = orderDate.plusDays(5);
    if (!this.result.isEmpty()) {
        filterByOrderDate(orderDateStart, orderDateEnd);
    } else {
        createResultForOrderDate(orderDateStart, orderDateEnd);
    }
    return this;
}
 
Example 14
Source File: Organisation_Test.java    From estatio with Apache License 2.0 5 votes vote down vote up
@Test
public void verify_works() throws Exception {

    // given
    Organisation organisation = new Organisation();
    organisation.clockService = mockClockService;
    organisation.organisationPreviousNameRepository = mockOrganisationPreviousNameRepository;

    final String looked_up_name = "Looked Up Name";
    final String chamberOfCommerceCode = "123456789";
    final LocalDate previousNameEndDate = new LocalDate(2017, 01,01);
    OrganisationNameNumberViewModel vm = new OrganisationNameNumberViewModel(looked_up_name, chamberOfCommerceCode, previousNameEndDate.plusDays(1));


    // expect
    context.checking(new Expectations(){{
        oneOf(mockOrganisationPreviousNameRepository).newOrganisationPreviousName(null, previousNameEndDate);
    }});

    // when
    organisation.verify(vm);

    // then
    assertThat(organisation.getName()).isEqualTo(looked_up_name);
    assertThat(organisation.getChamberOfCommerceCode()).isEqualTo(chamberOfCommerceCode);
    assertThat(organisation.isVerified()).isTrue();

}
 
Example 15
Source File: DayIterator.java    From dhis2-android-datacapture with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected ArrayList<DateHolder> generatePeriod() {
    ArrayList<DateHolder> dates = new ArrayList<DateHolder>();
    checkDate = new LocalDate(cPeriod);

    int counter = 0;
    int quantity = checkDate.dayOfYear().getMaximumValue();

    while ((openFuturePeriods > 0 || currentDate.isAfter(checkDate)) && counter < quantity) {

        String date = checkDate.toString(DATE_FORMAT);

        String dName = checkDate.dayOfMonth().getAsString();
        String mName = checkDate.monthOfYear().getAsText();
        String yName = checkDate.year().getAsString();

        String label = String.format(DATE_LABEL_FORMAT, dName, mName, yName);


        if (checkDate.isBefore(maxDate) && isInInputPeriods(date)) {
            DateHolder dateHolder = new DateHolder(date, checkDate.toString(), label);
            dates.add(dateHolder);
        }

        counter++;
        checkDate = checkDate.plusDays(1);
    }

    Collections.reverse(dates);
    return dates;
}
 
Example 16
Source File: Occupancy_createEmptyTurnovers.java    From estatio with Apache License 2.0 5 votes vote down vote up
@Action()
public Occupancy $$(final LocalDate startDate, final LocalDate endDate) {
    if (!endDate.isBefore(startDate)){
        final List<TurnoverReportingConfig> configs = turnoverReportingConfigRepository.findByOccupancy(occupancy);
        LocalDate date = startDate;
        while (!date.isAfter(endDate)){
            for (TurnoverReportingConfig config : configs){
                config.produceEmptyTurnover(date);
            }
            date = date.plusDays(1);
        }
    }
    return occupancy;
}
 
Example 17
Source File: LocalDateForwardHandler.java    From objectlabkit with Apache License 2.0 5 votes vote down vote up
public LocalDate adjustDate(final LocalDate startDate, final int increment, final NonWorkingDayChecker<LocalDate> checker) {
    LocalDate date = startDate;
    while (checker.isNonWorkingDay(date)) {
        date = date.plusDays(increment);
    }
    return date;
}
 
Example 18
Source File: TurnoverEntryService.java    From estatio with Apache License 2.0 5 votes vote down vote up
public void produceEmptyTurnoversForPropertyAndPeriod(final LocalDate startDate, final LocalDate endDate, final Property property) {
    LocalDate date = startDate;
    while (!date.isAfter(endDate)){
        produceEmptyTurnoversFor(date, property);
        date = date.plusDays(1);
    }
}
 
Example 19
Source File: BiWeeklyPeriodFilter.java    From dhis2-android-datacapture with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static DateTime getStartDayOfNextMonthBiWeek(DateTime date){
    LocalDate localDate = new LocalDate(getStartDayOfFirstBiWeek(date));
    localDate = localDate.plusDays(28);
    return localDate.toDateTimeAtStartOfDay();
}
 
Example 20
Source File: MonthlyExpiryDayValidator.java    From dhis2-android-datacapture with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
protected LocalDate getMaxDateCanEdit() {
    LocalDate periodDate = LocalDate.parse(period, DateTimeFormat.forPattern(getDateFormat()));
    periodDate = periodDate.plusMonths(plusMonths());
    return periodDate.plusDays(expiryDays - 2);
}