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

x33g5p2x  于2022-01-17 转载在 其他  
字(10.9k)|赞(0)|评价(0)|浏览(303)

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

DateTime.isAfter介绍

暂无

代码示例

代码示例来源:origin: Graylog2/graylog2-server

private boolean compareDateTimes(String operator, DateTime left, DateTime right) {
  switch (operator) {
    case ">":
      return left.isAfter(right);
    case ">=":
      return !left.isBefore(right);
    case "<":
      return left.isBefore(right);
    case "<=":
      return !left.isAfter(right);
    default:
      return false;
  }
}

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

/**
 * Check if workunit needs to be created. Returns <code>true</code> If the
 * <code>updateTime</code> is greater than the <code>lowWatermark</code> and <code>maxLookBackTime</code>
 * <code>createTime</code> is not used. It exists for backward compatibility
 */
protected boolean shouldCreateWorkunit(long createTime, long updateTime, LongWatermark lowWatermark) {
 if (new DateTime(updateTime).isBefore(this.maxLookBackTime)) {
  return false;
 }
 return new DateTime(updateTime).isAfter(lowWatermark.getValue());
}

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

/**
 * Return true iff input folder time is between compaction.timebased.min.time.ago and
 * compaction.timebased.max.time.ago.
 */
protected boolean folderWithinAllowedPeriod(Path inputFolder, DateTime folderTime) {
 DateTime currentTime = new DateTime(this.timeZone);
 PeriodFormatter periodFormatter = getPeriodFormatter();
 DateTime earliestAllowedFolderTime = getEarliestAllowedFolderTime(currentTime, periodFormatter);
 DateTime latestAllowedFolderTime = getLatestAllowedFolderTime(currentTime, periodFormatter);
 if (folderTime.isBefore(earliestAllowedFolderTime)) {
  log.info(String.format("Folder time for %s is %s, earlier than the earliest allowed folder time, %s. Skipping",
    inputFolder, folderTime, earliestAllowedFolderTime));
  return false;
 } else if (folderTime.isAfter(latestAllowedFolderTime)) {
  log.info(String.format("Folder time for %s is %s, later than the latest allowed folder time, %s. Skipping",
    inputFolder, folderTime, latestAllowedFolderTime));
  return false;
 } else {
  return true;
 }
}

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

/**
 * Determine if the {@link Table} or {@link Partition} should be validated by checking if its create time
 * lies between maxLookBackTime and skipRecentThanTime window.
 */
private boolean shouldValidate(Partition partition) {
 for (String pathToken : this.ignoreDataPathIdentifierList) {
  if (partition.getDataLocation().toString().toLowerCase().contains(pathToken.toLowerCase())) {
   log.info("Skipping partition " + partition.getCompleteName() + " containing invalid token " + pathToken
     .toLowerCase());
   return false;
  }
 }
 try {
  long createTime = getPartitionCreateTime(partition.getName());
  boolean withinTimeWindow = new DateTime(createTime).isAfter(this.maxLookBackTime) && new DateTime(createTime)
    .isBefore(this.skipRecentThanTime);
  if (!withinTimeWindow) {
   log.info("Skipping partition " + partition.getCompleteName() + " as create time " + new DateTime(createTime)
     .toString() + " is not within validation time window ");
  } else {
   log.info("Validating partition " + partition.getCompleteName());
   return withinTimeWindow;
  }
 } catch (ParseException e) {
  Throwables.propagate(e);
 }
 return false;
}

代码示例来源:origin: apache/flume

if (fixed.isAfter(now) && fixed.minusMonths(1).isAfter(now)) {
 fixed = date.minusYears(1);
} else if (fixed.isBefore(now) && fixed.plusMonths(1).isBefore(now)) {
 fixed = date.plusYears(1);

代码示例来源:origin: Graylog2/graylog2-server

if (nextRotation.isAfter(now)) {
  final String message = new MessageFormat("Next rotation at {0}", Locale.ENGLISH)
      .format(new Object[]{nextRotation});
do {
  tmpAnchor = currentAnchor.withPeriodAdded(rotationPeriod, ++multiplicator);
} while (tmpAnchor.isBefore(now));

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

DateTime remainingEnd = totalInterval.getEnd();
for (Interval skipInterval : skipIntervals) {
 if (skipInterval.getStart().isBefore(remainingStart) && skipInterval.getEnd().isAfter(remainingStart)) {
  remainingStart = skipInterval.getEnd();
 } else if (skipInterval.getStart().isBefore(remainingEnd) && skipInterval.getEnd().isAfter(remainingEnd)) {
  remainingEnd = skipInterval.getStart();
 } else if (!remainingStart.isAfter(skipInterval.getStart()) && !remainingEnd.isBefore(skipInterval.getEnd())) {
  filteredIntervals.add(new Interval(remainingStart, skipInterval.getStart()));
  remainingStart = skipInterval.getEnd();

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

private static Interval computeMergedInterval(final List<DataSegment> segments)
{
 Preconditions.checkArgument(segments.size() > 0, "segments.size() > 0");
 DateTime start = null;
 DateTime end = null;
 for (final DataSegment segment : segments) {
  if (start == null || segment.getInterval().getStart().isBefore(start)) {
   start = segment.getInterval().getStart();
  }
  if (end == null || segment.getInterval().getEnd().isAfter(end)) {
   end = segment.getInterval().getEnd();
  }
 }
 return new Interval(start, end);
}

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

if (currMinTime != null && currMinTime.isBefore(min)) {
 min = currMinTime;
if (currMaxTime != null && currMaxTime.isAfter(max)) {
 max = currMaxTime;

代码示例来源:origin: killbill/killbill

public void assertDateWithin(final DateTime in, final DateTime lower, final DateTime upper) {
  assertTrue(in.isEqual(lower) || in.isAfter(lower), "in=" + in + ", lower=" + lower);
  assertTrue(in.isEqual(upper) || in.isBefore(upper), "in=" + in + ", upper=" + upper);
}

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

public boolean withinMinMaxRecordTime(final InputRow row)
{
 final boolean beforeMinimumMessageTime = ioConfig.getMinimumMessageTime().isPresent()
                      && ioConfig.getMinimumMessageTime().get().isAfter(row.getTimestamp());
 final boolean afterMaximumMessageTime = ioConfig.getMaximumMessageTime().isPresent()
                     && ioConfig.getMaximumMessageTime().get().isBefore(row.getTimestamp());
 if (!Intervals.ETERNITY.contains(row.getTimestamp())) {
  final String errorMsg = StringUtils.format(
    "Encountered row with timestamp that cannot be represented as a long: [%s]",
    row
  );
  throw new ParseException(errorMsg);
 }
 if (log.isDebugEnabled()) {
  if (beforeMinimumMessageTime) {
   log.debug(
     "CurrentTimeStamp[%s] is before MinimumMessageTime[%s]",
     row.getTimestamp(),
     ioConfig.getMinimumMessageTime().get()
   );
  } else if (afterMaximumMessageTime) {
   log.debug(
     "CurrentTimeStamp[%s] is after MaximumMessageTime[%s]",
     row.getTimestamp(),
     ioConfig.getMaximumMessageTime().get()
   );
  }
 }
 return !beforeMinimumMessageTime && !afterMaximumMessageTime;
}

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

timelineObjects.add(Pair.of(timelineObject, underlyingInterval));
} else {
 final DateTime start = underlyingInterval.getStart().isBefore(mergedUnderlyingInterval.getStart())
             ? underlyingInterval.getStart()
             : mergedUnderlyingInterval.getStart();
 final DateTime end = underlyingInterval.getEnd().isAfter(mergedUnderlyingInterval.getEnd())
            ? underlyingInterval.getEnd()
            : mergedUnderlyingInterval.getEnd();

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

.isAfter(firstEntry.getInterval().getStart())) {
 retVal.set(
   0,
if (interval.overlaps(lastEntry.getInterval()) && interval.getEnd().isBefore(lastEntry.getInterval().getEnd())) {
 retVal.set(
   retVal.size() - 1,

代码示例来源:origin: killbill/killbill

@Override
public int compareTo(final SubscriptionBaseEvent other) {
  if (other == null) {
    throw new IllegalArgumentException("IEvent is compared to a null instance");
  }
  if (effectiveDate.isBefore(other.getEffectiveDate())) {
    return -1;
  } else if (effectiveDate.isAfter(other.getEffectiveDate())) {
    return 1;
  } else if (getType() != other.getType()) {
    return (getType() == EventType.PHASE) ? -1 : 1;
  } else if (getType() == EventType.API_USER) {
    return ((ApiEvent) this).getApiEventType().compareTo(((ApiEvent) other).getApiEventType());
  } else {
    return uuid.compareTo(other.getId());
  }
}

代码示例来源:origin: killbill/killbill

final boolean catalogOlderThanSubscriptionStartDate = !subscriptionStartDate.isBefore(catalogEffectiveDate);
if (oldestCatalog || // Prevent issue with time granularity -- see #760
  if (plan.getEffectiveDateForExistingSubscriptions() != null) { // If it is null, any change to this catalog does not apply to existing subscriptions
    final DateTime existingSubscriptionDate = CatalogDateHelper.toUTCDateTime(plan.getEffectiveDateForExistingSubscriptions());
    if (requestedDate.isAfter(existingSubscriptionDate)) { // This plan is now applicable to existing subs
      return new CatalogPlanEntry(c, plan);

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

latest = compactionStartTime.minus(minTimeAgo);
if (earliest.isBefore(folderTime) && latest.isAfter(folderTime)) {
 log.debug("{} falls in the user defined time range", dataset.datasetRoot());
 return new Result(true, "");

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

if (currKey.contains(entryInterval)) {
 return true;
} else if (currKey.getStart().isBefore(entryInterval.getStart())) {
 entryInterval = new Interval(currKey.getEnd(), entryInterval.getEnd());
} else {
 addIntervalToTimeline(new Interval(entryInterval.getStart(), currKey.getStart()), entry, timeline);
 if (entryInterval.getEnd().isAfter(currKey.getEnd())) {
  entryInterval = new Interval(currKey.getEnd(), entryInterval.getEnd());
 } else {
} else if (currKey.getStart().isBefore(entryInterval.getStart())) {
 addIntervalToTimeline(new Interval(currKey.getStart(), entryInterval.getStart()), oldEntry, timeline);
} else if (entryInterval.getEnd().isBefore(currKey.getEnd())) {
 addIntervalToTimeline(new Interval(entryInterval.getEnd(), currKey.getEnd()), oldEntry, timeline);

代码示例来源:origin: linkedin/camus

private boolean shouldProcessDir(Path inputDir, DateTime inputDate, DateTime minDaysAgo, DateTime maxDaysAgo) {
 if (inputDate.isAfter(minDaysAgo)) {
  LOG.info(String.format("folder %s with timestamp %s is later than latest allowed timestamp %s. Skipping",
    inputDir, inputDate, minDaysAgo));
  return false;
 }
 if (inputDate.isBefore(maxDaysAgo)) {
  LOG.info(String.format("folder %s with timestamp %s is earlier than earliest allowed timestamp %s. Skipping",
    inputDir, inputDate, maxDaysAgo));
  return false;
 }
 return true;
}

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

@Test
public void testTimeseriesNoAggregators()
{
 Granularity gran = Granularities.DAY;
 TimeseriesQuery query = Druids.newTimeseriesQueryBuilder()
                .dataSource(QueryRunnerTestHelper.dataSource)
                .granularity(gran)
                .intervals(QueryRunnerTestHelper.fullOnIntervalSpec)
                .descending(descending)
                .build();
 Iterable<Result<TimeseriesResultValue>> results = runner.run(QueryPlus.wrap(query), CONTEXT).toList();
 final DateTime expectedLast = descending ?
                QueryRunnerTestHelper.earliest :
                QueryRunnerTestHelper.last;
 Result lastResult = null;
 for (Result<TimeseriesResultValue> result : results) {
  DateTime current = result.getTimestamp();
  Assert.assertFalse(
    StringUtils.format("Timestamp[%s] > expectedLast[%s]", current, expectedLast),
    descending ? current.isBefore(expectedLast) : current.isAfter(expectedLast)
  );
  Assert.assertEquals(ImmutableMap.of(), result.getValue().getBaseObject());
  lastResult = result;
 }
 Assert.assertEquals(lastResult.toString(), expectedLast, lastResult.getTimestamp());
}

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

Assert.assertFalse(
  StringUtils.format("Timestamp[%s] > expectedLast[%s]", current, expectedLast),
  descending ? current.isBefore(expectedLast) : current.isAfter(expectedLast)
);

相关文章

DateTime类方法