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

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

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

LocalDateTime.minus介绍

[英]Returns a copy of this datetime with the specified duration taken away.

If the amount is zero or null, then this is returned.
[中]返回此datetime的副本,指定的持续时间已结束。
如果金额为零或空,则返回this

代码示例

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

@Override
 protected List<FileStatus> getFilesAtPath(FileSystem fs, Path path, PathFilter fileFilter) throws IOException {
  DateTimeFormatter formatter = DateTimeFormat.forPattern(datePattern);
  LocalDateTime endDate = currentTime;
  LocalDateTime startDate = endDate.minus(this.lookbackPeriod);

  DateRangeIterator dateRangeIterator = new DateRangeIterator(startDate, endDate, isPatternHourly);
  List<FileStatus> fileStatuses = Lists.newArrayList();
  while (dateRangeIterator.hasNext()) {
   Path pathWithDateTime = new Path(path, dateRangeIterator.next().toString(formatter));
   fileStatuses.addAll(super.getFilesAtPath(fs, pathWithDateTime, fileFilter));
  }
  return fileStatuses;
 }
}

代码示例来源:origin: org.apache.gobblin/gobblin-data-management

@Override
 protected List<FileStatus> getFilesAtPath(FileSystem fs, Path path, PathFilter fileFilter) throws IOException {
  DateTimeFormatter formatter = DateTimeFormat.forPattern(datePattern);
  LocalDateTime endDate = currentTime;
  LocalDateTime startDate = endDate.minus(this.lookbackPeriod);

  DateRangeIterator dateRangeIterator = new DateRangeIterator(startDate, endDate, isPatternHourly);
  List<FileStatus> fileStatuses = Lists.newArrayList();
  while (dateRangeIterator.hasNext()) {
   Path pathWithDateTime = new Path(path, dateRangeIterator.next().toString(formatter));
   fileStatuses.addAll(super.getFilesAtPath(fs, pathWithDateTime, fileFilter));
  }
  return fileStatuses;
 }
}

代码示例来源:origin: tcplugins/tcWebHooks

private WebHookHistoryRepository setupMocks() {
  Period fiveDays = new Period().withDays(5);
  MockitoAnnotations.initMocks(this);
  stats01.setStatusCode(200);
  stats01.setInitTimeStamp(LocalDateTime.now().minus(fiveDays).toDate());
  stats02.setStatusCode(403);
  stats02.setErrored(true);
  stats02.setInitTimeStamp(LocalDateTime.now().minus(fiveDays).toDate());
  WebHook webhook01 = new SimpleMockedWebHook(stats01);
  WebHook webhook02 = new SimpleMockedWebHook(stats02);
  when(sBuild01.getBuildTypeId()).thenReturn("bt01");
  when(sBuild02.getBuildTypeId()).thenReturn("bt02");
  when(sBuild01.getProjectId()).thenReturn("project01");
  when(sBuild02.getProjectId()).thenReturn("project01");
  when(sBuild01.getBuildId()).thenReturn(01L);
  when(sBuild02.getBuildId()).thenReturn(02L);
  
  whc1 = new WebHookConfig("project01", "MyProject", "http://url/1", true, new BuildState().setAllEnabled(), "testFormat", "jsonTemplate", true, true, null, null);
  whc2 = new WebHookConfig("project01", "MyProject", "http://url/2", true, new BuildState().setAllEnabled(), "testFormat", "jsonTemplate", true, true, null, null);
  
  WebHookHistoryRepository historyRepository = new WebHookHistoryRepositoryImpl();
  historyRepository.addHistoryItem(new WebHookHistoryItem(whc1, webhook01.getExecutionStats(), sBuild01, null));
  historyRepository.addHistoryItem(new WebHookHistoryItem(whc2, webhook02.getExecutionStats(), sBuild02, null));
  return historyRepository;
}

相关文章