org.joda.time.LocalDate#minusDays ( )源码实例Demo

下面列出了org.joda.time.LocalDate#minusDays ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: prayer-times-android   文件: WebTimes.java
@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);
    }
}
 
源代码2 项目: prayer-times-android   文件: WebTimes.java
@NonNull
public LocalDate getLastSyncedDay() {
    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.minusDays(1);
        }
        i++;
        date = date.plusDays(1);
    }
}
 
源代码3 项目: prayer-times-android   文件: Times.java
@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;
}
 
public Optional<LocalDate> getPreviousDateWithMatches(LocalDate date) {
  LocalDate yesterday = date.minusDays(1);
  GcsFilename gcsFilename = getGcsFilename(yesterday);
  if (gcsUtils.existsAndNotEmpty(gcsFilename)) {
    return Optional.of(yesterday);
  }
  logger.atWarning().log("Could not find previous file from date %s", yesterday);

  for (LocalDate dateToCheck = yesterday.minusDays(1);
      !dateToCheck.isBefore(date.minusMonths(1));
      dateToCheck = dateToCheck.minusDays(1)) {
    gcsFilename = getGcsFilename(dateToCheck);
    if (gcsUtils.existsAndNotEmpty(gcsFilename)) {
      return Optional.of(dateToCheck);
    }
  }
  return Optional.empty();
}
 
源代码5 项目: prayer-times-android   文件: WebTimes.java
@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);
    }
}
 
源代码6 项目: prayer-times-android   文件: Times.java
@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;
}
 
@Test
public void find_by_property_active_on_date_works() throws Exception {

    // given
    TurnoverReportingConfig config = turnoverReportingConfigRepository.listAll().get(0);
    final LocalDate occupancyStartDate = new LocalDate(2010, 7, 15);
    assertThat(config.getOccupancy().getStartDate()).isEqualTo(occupancyStartDate);
    assertThat(config.getStartDate()).isEqualTo(new LocalDate(2014,1,2));

    // when, then
    final LocalDate firstDayOfOccupancyMonth = new LocalDate(2010, 7, 1);
    assertThat(turnoverReportingConfigRepository.findByPropertyActiveOnDate(Property_enum.OxfGb.findUsing(serviceRegistry2), firstDayOfOccupancyMonth)).hasSize(0);

    // and when
    config.setStartDate(occupancyStartDate);
    // then
    assertThat(turnoverReportingConfigRepository.findByPropertyActiveOnDate(Property_enum.OxfGb.findUsing(serviceRegistry2), firstDayOfOccupancyMonth)).hasSize(1);
    final LocalDate lastDayOfOccupancyMonth = new LocalDate(2010, 7, 31);
    assertThat(turnoverReportingConfigRepository.findByPropertyActiveOnDate(Property_enum.OxfGb.findUsing(serviceRegistry2), lastDayOfOccupancyMonth)).hasSize(1);

    // and when
    final LocalDate lastDayOfPreviousOccupancyMonth = firstDayOfOccupancyMonth.minusDays(1);
    // then
    assertThat(turnoverReportingConfigRepository.findByPropertyActiveOnDate(Property_enum.OxfGb.findUsing(serviceRegistry2), lastDayOfPreviousOccupancyMonth)).hasSize(0);

    // and when occupancy ends before next month
    config.getOccupancy().setEndDate(lastDayOfOccupancyMonth);
    final LocalDate firstDayOfNextOccupancyMonth = new LocalDate(2010, 8, 1);
    assertThat(turnoverReportingConfigRepository.findByPropertyActiveOnDate(Property_enum.OxfGb.findUsing(serviceRegistry2), firstDayOfNextOccupancyMonth)).hasSize(0);

}
 
public BiWeekIterator(int openFP, String[] dataInputPeriods) {
    super(dataInputPeriods);
    openFuturePeriods = openFP;
    cPeriod = new LocalDate(currentDate.withWeekOfWeekyear(1).withDayOfWeek(1));
    checkDate = new LocalDate(cPeriod);
    maxDate = new LocalDate(currentDate.getYear(), currentDate.getMonthOfYear(), currentDate.getDayOfMonth());
    maxDate = maxDate.minusDays(currentDate.getDayOfWeek());
    if(openFuturePeriods>1) {
        for (int i = 0; i < (openFuturePeriods-1) / 2; i++) {
            maxDate = maxDate.plusWeeks(2);
        }
    }
}
 
源代码9 项目: dhis2-android-datacapture   文件: WeekIterator.java
public WeekIterator(int openFP, String[] dataInputPeriods) {
    super(dataInputPeriods);
    openFuturePeriods = openFP;
    cPeriod = new LocalDate(currentDate.withWeekOfWeekyear(1).withDayOfWeek(1));
    checkDate = new LocalDate(cPeriod);
    maxDate = new LocalDate(currentDate.getYear(), currentDate.getMonthOfYear(), currentDate.getDayOfMonth());
    maxDate = maxDate.minusDays(currentDate.getDayOfWeek());
    for (int i = 0; i < openFuturePeriods; i++) {
        maxDate = maxDate.plusWeeks(1);
    }
}
 
@Test
public void testCanNotEditWithPeriodWithSameMinusDaysAsExpiryDays() {
    LocalDate todayDate = new LocalDate();
    int expiryDays = 5;
    todayDate = todayDate.minusDays(expiryDays);
    ExpiryDayValidator expiryDayValidator = new ExpiryDayValidator(expiryDays,
            todayDate.toString(PATTERN));
    assertFalse(expiryDayValidator.canEdit());
}
 
@Test
public void testCanEditDateWithLessMinusDaysThanExpiryDays() {
    LocalDate todayDate = new LocalDate();
    int expiryDays = 5;
    todayDate = todayDate.minusDays(expiryDays - 1);
    ExpiryDayValidator expiryDayValidator = new ExpiryDayValidator(expiryDays,
            todayDate.toString(PATTERN));
    assertTrue(expiryDayValidator.canEdit());
}
 
@Test
public void testCanNotEditDateWithMorePlusDaysThanExpiryDays() {
    LocalDate todayDate = new LocalDate();
    int expiryDays = 5;
    todayDate = todayDate.minusDays(expiryDays + 1);
    ExpiryDayValidator expiryDayValidator = new ExpiryDayValidator(expiryDays,
            todayDate.toString(PATTERN));
    assertFalse(expiryDayValidator.canEdit());
}
 
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;
}
 
源代码14 项目: estatio   文件: OrderMenu.java
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;
}
 
源代码15 项目: adwords-alerting   文件: DateRange.java
/**
 * Parse DateRange in ReportDefinitionDateRangeType enum format.
 */
private static DateRange parseEnumFormat(String dateRange) {
  ReportDefinitionDateRangeType dateRangeType;
  try {
    dateRangeType = ReportDefinitionDateRangeType.valueOf(dateRange);
  } catch (IllegalArgumentException e) {
    throw new IllegalArgumentException("Unknown DateRange type: " + dateRange);
  }

  LocalDate today = LocalDate.now();
  LocalDate startDate;
  LocalDate endDate;
  switch (dateRangeType) {
    case TODAY:
      startDate = endDate = today;
      break;
    case YESTERDAY:
      startDate = endDate = today.minusDays(1);
      break;
    case LAST_7_DAYS:
      startDate = today.minusDays(7);
      endDate = today.minusDays(1);
      break;
    case LAST_WEEK:
      LocalDate.Property lastWeekProp = today.minusWeeks(1).dayOfWeek();
      startDate = lastWeekProp.withMinimumValue();
      endDate = lastWeekProp.withMaximumValue();
      break;
    case THIS_MONTH:
      LocalDate.Property thisMonthProp = today.dayOfMonth();
      startDate = thisMonthProp.withMinimumValue();
      endDate = thisMonthProp.withMaximumValue();
      break;
    case LAST_MONTH:
      LocalDate.Property lastMonthProp = today.minusMonths(1).dayOfMonth();
      startDate = lastMonthProp.withMinimumValue();
      endDate = lastMonthProp.withMaximumValue();
      break;
    case LAST_14_DAYS:
      startDate = today.minusDays(14);
      endDate = today.minusDays(1);
      break;
    case LAST_30_DAYS:
      startDate = today.minusDays(30);
      endDate = today.minusDays(1);
      break;
    case THIS_WEEK_SUN_TODAY:
      // Joda-Time uses the ISO standard Monday to Sunday week.
      startDate = today.minusWeeks(1).dayOfWeek().withMaximumValue();
      endDate = today;
      break;
    case THIS_WEEK_MON_TODAY:
      startDate = today.dayOfWeek().withMinimumValue();
      endDate = today;
      break;
    case LAST_WEEK_SUN_SAT:
      startDate = today.minusWeeks(2).dayOfWeek().withMaximumValue();
      endDate = today.minusWeeks(1).dayOfWeek().withMaximumValue().minusDays(1);
      break;
      // Don't support the following enums
    case LAST_BUSINESS_WEEK:
    case ALL_TIME:
    case CUSTOM_DATE:
    default:
      throw new IllegalArgumentException("Unsupported DateRange type: " + dateRange);
  }

  return new DateRange(startDate, endDate);
}
 
private static DateTime getStartDayOfPreviousMonthBiWeek(DateTime date){
    LocalDate localDate = new LocalDate(getStartDayOfFirstBiWeek(date));
    localDate = localDate.minusDays(14);
    return localDate.toDateTimeAtStartOfDay();
}
 
private static DateTime getEndDayOfPreviousMonthBiWeek(DateTime date){
    DateTime startDay = getStartDayOfFirstBiWeek(date);
    LocalDate localDate = new LocalDate(startDay);
    localDate = localDate.minusDays( 14 );
    return localDate.toDateTimeAtStartOfDay();
}
 
源代码18 项目: fenixedu-academic   文件: SummariesControlAction.java
private List<DetailSummaryElement> getExecutionCourseResume(final ExecutionSemester executionSemester,
        Collection<Professorship> professorships) {
    List<DetailSummaryElement> allListElements = new ArrayList<DetailSummaryElement>();
    LocalDate today = new LocalDate();
    LocalDate oneWeekBeforeToday = today.minusDays(8);
    for (Professorship professorship : professorships) {
        BigDecimal lessonsGiven = EMPTY;
        BigDecimal summariesGiven = EMPTY;
        BigDecimal summariesGivenPercentage = EMPTY;
        BigDecimal notTaughtSummaries = EMPTY;
        BigDecimal notTaughtSummariesPercentage = EMPTY;
        BigDecimal onlineLessons = EMPTY;
        BigDecimal onlineLessonsPercentage = EMPTY;
        if (professorship.belongsToExecutionPeriod(executionSemester)) {
            for (Shift shift : professorship.getExecutionCourse().getAssociatedShifts()) {
                lessonsGiven = lessonsGiven.add(BigDecimal.valueOf(shift.getNumberOfLessonInstances()));

                // Get the number of summaries given
                summariesGiven = getSummariesGiven(professorship, shift, summariesGiven, oneWeekBeforeToday);
                // Get the number of not taught summaries
                notTaughtSummaries = getNotTaughtSummaries(professorship, shift, notTaughtSummaries, oneWeekBeforeToday);
                // Get the number of online lessons
                onlineLessons = getOnlineLessons(professorship, shift, onlineLessons, oneWeekBeforeToday);
            }
            summariesGiven = summariesGiven.setScale(1, RoundingMode.HALF_UP);
            notTaughtSummaries = notTaughtSummaries.setScale(1, RoundingMode.HALF_UP);
            onlineLessons = onlineLessons.setScale(1, RoundingMode.HALF_UP);

            if (lessonsGiven.signum() == 1) {
                summariesGivenPercentage = summariesGiven.divide(lessonsGiven, 3, BigDecimal.ROUND_CEILING)
                        .multiply(BigDecimal.valueOf(100));
                notTaughtSummariesPercentage = notTaughtSummaries.divide(lessonsGiven, 3, BigDecimal.ROUND_CEILING)
                        .multiply(BigDecimal.valueOf(100));
                onlineLessonsPercentage = onlineLessons.divide(lessonsGiven, 3, BigDecimal.ROUND_CEILING)
                        .multiply(BigDecimal.valueOf(100));
            }

            Teacher teacher = professorship.getTeacher();
            String categoryName = null;
            if (teacher != null) {
                final Optional<TeacherAuthorization> authorization =
                        teacher.getTeacherAuthorization(executionSemester.getAcademicInterval());

                categoryName =
                        authorization.isPresent() ? authorization.get().getTeacherCategory().getName().getContent() : null;

            }

            String siglas = getSiglas(professorship);

            String teacherEmail =
                    professorship.getPerson().getDefaultEmailAddress() != null ? professorship.getPerson()
                            .getDefaultEmailAddress().getPresentationValue() : null;

            DetailSummaryElement listElementDTO =
                    new DetailSummaryElement(professorship.getPerson().getName(), professorship.getExecutionCourse()
                            .getNome(), teacher != null ? teacher.getTeacherId() : null, teacherEmail, categoryName,
                            summariesGiven, notTaughtSummaries, onlineLessons, siglas, lessonsGiven, summariesGivenPercentage,
                            notTaughtSummariesPercentage, onlineLessonsPercentage);

            allListElements.add(listElementDTO);
        }
    }
    return allListElements;
}
 
源代码19 项目: activiti6-boot2   文件: DateUtil.java
public static Date subtractDate(Date startDate, Integer years, Integer months, Integer days) {

        LocalDate currentDate = new LocalDate(startDate);

        currentDate = currentDate.minusYears(years);
        currentDate = currentDate.minusMonths(months);
        currentDate = currentDate.minusDays(days);

        return currentDate.toDate();
    }
 
源代码20 项目: flowable-engine   文件: DateUtil.java
public static Date subtractDate(Object startDate, Object years, Object months, Object days) {

        LocalDate currentDate = new LocalDate(startDate);

        currentDate = currentDate.minusYears(intValue(years));
        currentDate = currentDate.minusMonths(intValue(months));
        currentDate = currentDate.minusDays(intValue(days));

        return currentDate.toDate();
    }