org.joda.time.LocalDateTime.minusDays()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(134)

本文整理了Java中org.joda.time.LocalDateTime.minusDays()方法的一些代码示例,展示了LocalDateTime.minusDays()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDateTime.minusDays()方法的具体详情如下:
包路径:org.joda.time.LocalDateTime
类名称:LocalDateTime
方法名:minusDays

LocalDateTime.minusDays介绍

[英]Returns a copy of this datetime minus the specified number of days.

This LocalDateTime instance is immutable and unaffected by this method call.

The following three lines are identical in effect:

LocalDateTime subtracted = dt.minusDays(6); 
LocalDateTime subtracted = dt.minus(Period.days(6)); 
LocalDateTime subtracted = dt.withFieldAdded(DurationFieldType.days(), -6);

[中]返回此datetime减去指定天数的副本。
此LocalDateTime实例是不可变的,不受此方法调用的影响。
以下三行实际上是相同的:

LocalDateTime subtracted = dt.minusDays(6); 
LocalDateTime subtracted = dt.minus(Period.days(6)); 
LocalDateTime subtracted = dt.withFieldAdded(DurationFieldType.days(), -6);

代码示例

代码示例来源:origin: apache/incubator-gobblin

String startDate = endDate.minusDays(i).toString(formatter);
Path subDirPath = new Path(baseDir2, new Path(startDate));
fs.mkdirs(subDirPath);

代码示例来源:origin: apache/incubator-gobblin

@Test
 public void testIterator() {
  LocalDateTime endDate = new LocalDateTime(2017, 1, 1, 0, 0, 0);
  LocalDateTime startDate = endDate.minusHours(2);
  String datePattern = "HH/yyyy/MM/dd";
  DateTimeFormatter format = DateTimeFormat.forPattern(datePattern);
  TimeAwareRecursiveCopyableDataset.DateRangeIterator dateRangeIterator =
    new TimeAwareRecursiveCopyableDataset.DateRangeIterator(startDate, endDate, true);
  LocalDateTime dateTime = dateRangeIterator.next();
  Assert.assertEquals(dateTime.toString(format), "22/2016/12/31");
  dateTime = dateRangeIterator.next();
  Assert.assertEquals(dateTime.toString(format), "23/2016/12/31");
  dateTime = dateRangeIterator.next();
  Assert.assertEquals(dateTime.toString(format), "00/2017/01/01");
  Assert.assertEquals(dateRangeIterator.hasNext(), false);

  datePattern = "yyyy/MM/dd";
  format = DateTimeFormat.forPattern(datePattern);
  startDate = endDate.minusDays(1);
  dateRangeIterator = new TimeAwareRecursiveCopyableDataset.DateRangeIterator(startDate, endDate, false);
  dateTime = dateRangeIterator.next();
  Assert.assertEquals(dateTime.toString(format), "2016/12/31");
  dateTime = dateRangeIterator.next();
  Assert.assertEquals(dateTime.toString(format), "2017/01/01");
  Assert.assertEquals(dateRangeIterator.hasNext(), false);
 }
}

代码示例来源:origin: dlew/joda-time-android

LocalDateTime yesterdayLdt = todayLdt.minusDays(1);
LocalDateTime tomorrowLdt = todayLdt.plusDays(1);

代码示例来源:origin: ORCID/ORCID-Source

@Override
synchronized public void processUnverifiedEmails7Days() {
  LOGGER.info("About to process unverIfied emails for reminder");
  List<Pair<String, Date>> elements = Collections.<Pair<String, Date>> emptyList();
  do {
    elements = profileDaoReadOnly.findEmailsUnverfiedDays(verifyReminderAfterDays, 100, EmailEventType.VERIFY_EMAIL_7_DAYS_SENT);
    LOGGER.info("Got batch of {} profiles with unverified emails for reminder", elements.size());
    LocalDateTime now = LocalDateTime.now();
    Date tooOld = now.minusDays(emailTooOld).toDate();
    for (Pair<String, Date> element : elements) {
      if(element.getRight() == null || element.getRight().after(tooOld)) {
        processUnverifiedEmails7DaysInTransaction(element.getLeft());
      } else {
        // Mark is as too old to send the verification email
        markUnverifiedEmailAsTooOld(element.getLeft());
      }
    }
  } while (!elements.isEmpty());
}

代码示例来源:origin: org.kuali.kpme/kpme-tk-lm-impl

actualStartDate = startDate.minusDays(daysToMinus);
int daysToAdd = 0;
if(endDate.getDayOfWeek() != startDay) {
    display.append(weekStart.toString(TkConstants.DT_ABBREV_DATE_FORMAT));
    display.append(" - ");
    display.append(weekEnd.minusDays(1).toString(TkConstants.DT_ABBREV_DATE_FORMAT));
    weekDates.put("Week "+week, display.toString());
    weekStart = currentDate;

代码示例来源:origin: org.kuali.kpme/kpme-tk-lm-impl

actualStartDate = startDate.minusDays(daysToMinus);
int daysToAdd = 0;
if(endDate.getDayOfWeek() != DateTimeConstants.SUNDAY) {
    display.append(startDateString);
    display.append(" - ");
    String endDateString = weekEnd.minusDays(1).isAfter(endDate) ? 
        endDate.toString(TkConstants.DT_ABBREV_DATE_FORMAT) : weekEnd.minusDays(1).toString(TkConstants.DT_ABBREV_DATE_FORMAT);
    display.append(endDateString);
    weekDates.put(weekString, display.toString());

相关文章