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

x33g5p2x  于2022-01-30 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(135)

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

Seconds.getSeconds介绍

[英]Gets the number of seconds that this period represents.
[中]获取此句点表示的秒数。

代码示例

代码示例来源:origin: stackoverflow.com

DateTime now = DateTime.now();
DateTime dateTime = now.plusMinutes(10);
Seconds seconds = Seconds.secondsBetween(now, dateTime);
System.out.println(seconds.getSeconds());

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

@VisibleForTesting
static int parsePeriodToSeconds(String periodStr) {
 try {
  return Period.parse(periodStr.toUpperCase(), PERIOD_FORMATTER).toStandardSeconds().getSeconds();
 } catch(ArithmeticException ae) {
  throw new RuntimeException(String.format("Reporting interval is too long. Max: %d seconds.", Integer.MAX_VALUE));
 }
}

代码示例来源:origin: prestodb/presto

private static boolean isLeaked(Map<QueryId, BasicQueryInfo> queryIdToInfo, QueryId queryId)
{
  BasicQueryInfo queryInfo = queryIdToInfo.get(queryId);
  if (queryInfo == null) {
    return true;
  }
  DateTime queryEndTime = queryInfo.getQueryStats().getEndTime();
  if (queryInfo.getState() == RUNNING || queryEndTime == null) {
    return false;
  }
  return secondsBetween(queryEndTime, now()).getSeconds() >= DEFAULT_LEAK_CLAIM_DELTA_SEC;
}

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

public ConvertedTime getConvertedTime(long duration) {
  Set<Seconds> keys = RULES.keySet();
  for (Seconds seconds : keys) {
    if (duration <= seconds.getSeconds()) {
      return RULES.get(seconds).getConvertedTime(duration);
    }
  }
  return new TimeConverter.OverTwoYears().getConvertedTime(duration);
}

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

@VisibleForTesting
int resolvedSecondsAgo(String streamId, String conditionId) {
  final Optional<Alert> lastTriggeredAlert = getLastTriggeredAlert(streamId, conditionId);
  if (!lastTriggeredAlert.isPresent()) {
    return -1;
  }
  final Alert mostRecentAlert = lastTriggeredAlert.get();
  final DateTime resolvedAt = mostRecentAlert.getResolvedAt();
  if (resolvedAt == null || !isResolved(mostRecentAlert)) {
    return -1;
  }
  return Seconds.secondsBetween(resolvedAt, Tools.nowUTC()).getSeconds();
}

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

/**
 * Formats an elapsed time in a format like "MM:SS" or "H:MM:SS" (using a form
 * suited to the current locale), similar to that used on the call-in-progress
 * screen.
 *
 * See {@link android.text.format.DateUtils#formatElapsedTime} for full docs.
 *
 * @param recycle {@link StringBuilder} to recycle, or null to use a temporary one.
 * @param elapsedDuration the elapsed duration
 */
public static String formatElapsedTime(StringBuilder recycle, ReadableDuration elapsedDuration) {
  return android.text.format.DateUtils.formatElapsedTime(recycle,
    elapsedDuration.toDuration().toStandardSeconds().getSeconds());
}

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

/**
   * Calculate the number of seconds in the given time range.
   *
   * @param timeRange the {@link TimeRange}
   * @return the number of seconds in the given time range or 0 if an error occurred.
   */
  public static int toSeconds(TimeRange timeRange) {
    if (timeRange.getFrom() == null || timeRange.getTo() == null) {
      return 0;
    }

    try {
      return Seconds.secondsBetween(timeRange.getFrom(), timeRange.getTo()).getSeconds();
    } catch (IllegalArgumentException e) {
      return 0;
    }
  }
}

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

@Override
public boolean shouldRepeatNotifications(AlertCondition alertCondition, Alert alert) {
  // Do not repeat notifications if alert has no state, is resolved or the option to repeat notifications is disabled
  if (!alert.isInterval() || isResolved(alert) || !alertCondition.shouldRepeatNotifications()) {
    return false;
  }
  // Repeat notifications if no grace period is set, avoiding looking through the notification history
  if (alertCondition.getGrace() == 0) {
    return true;
  }
  AlarmCallbackHistory lastTriggeredAlertHistory = null;
  for (AlarmCallbackHistory history : alarmCallbackHistoryService.getForAlertId(alert.getId())) {
    if (lastTriggeredAlertHistory == null || lastTriggeredAlertHistory.createdAt().isBefore(history.createdAt())) {
      lastTriggeredAlertHistory = history;
    }
  }
  // Repeat notifications if no alert was ever triggered for this condition
  if (lastTriggeredAlertHistory == null) {
    return true;
  }
  final int lastAlertSecondsAgo = Seconds.secondsBetween(lastTriggeredAlertHistory.createdAt(), Tools.nowUTC()).getSeconds();
  return lastAlertSecondsAgo >= alertCondition.getGrace() * 60;
}

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

long count;
if (Minutes.minutesIn(interval).isLessThan(Minutes.ONE)) {
  count = Seconds.secondsIn(interval).getSeconds();
  if (past) {
    if (abbrevRelative) {

代码示例来源:origin: Teradata/kylo

private static String getSecondsCron(Period p) {
  Integer sec = p.getSeconds();
  Seconds s = p.toStandardSeconds();
  Integer seconds = s.getSeconds();
  String str = "0" + (sec > 0 ? "/" + sec : "");
  if (seconds > 60) {
    str = sec + "";
  }
  return str;
}

代码示例来源:origin: prestodb/presto

assertFunction("date_diff('second', " + baseDateTimeLiteral + ", " + TIMESTAMP_LITERAL + ")", BIGINT, (long) secondsBetween(baseDateTime, TIMESTAMP).getSeconds());
assertFunction("date_diff('minute', " + baseDateTimeLiteral + ", " + TIMESTAMP_LITERAL + ")", BIGINT, (long) minutesBetween(baseDateTime, TIMESTAMP).getMinutes());
assertFunction("date_diff('hour', " + baseDateTimeLiteral + ", " + TIMESTAMP_LITERAL + ")", BIGINT, (long) hoursBetween(baseDateTime, TIMESTAMP).getHours());
assertFunction("date_diff('second', " + weirdBaseDateTimeLiteral + ", " + WEIRD_TIMESTAMP_LITERAL + ")",
    BIGINT,
    (long) secondsBetween(weirdBaseDateTime, WEIRD_TIMESTAMP).getSeconds());
assertFunction("date_diff('minute', " + weirdBaseDateTimeLiteral + ", " + WEIRD_TIMESTAMP_LITERAL + ")",
    BIGINT,

代码示例来源:origin: org.wisdom-framework/wisdom-executors

/**
 * Translates the given (Joda) Period to duration in seconds.
 *
 * @param period the period
 * @return the duration representing the same amount of time in seconds
 */
public static long toDuration(Period period) {
  return period.toStandardSeconds().getSeconds();
}

代码示例来源:origin: com.linkedin.datafu/datafu

public Sessionize(String timeSpec)
{
 Period p = new Period("PT" + timeSpec.toUpperCase());
 this.millis = p.toStandardSeconds().getSeconds() * 1000;
 cleanup();
}

代码示例来源:origin: com.atlassian.jira/jira-core

@Override
  public void doUpgrade(final boolean setupMode) throws Exception
  {
    final DateTime startedAt = new DateTime();
    int deletedGadgets = Delete.from(GADGET_TABLE).whereLike(GADGET_URI_COLUMN, NEWS_GADGET_URI).execute(ofBizDelegator);
    log.info(String.format("Upgrade task took %d seconds to remove %d news gadgets.", Seconds.secondsBetween(startedAt, new DateTime()).getSeconds(), deletedGadgets));
  }
}

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

public void on(DateTime instant, Runnable runnable) {
  if (LOGGER.isTraceEnabled()) {
    LOGGER.trace("schedule runnable[%s] on %s", runnable, instant);
  }
  DateTime now = DateTime.now();
  E.illegalArgumentIf(instant.isBefore(now));
  Seconds seconds = Seconds.secondsBetween(now, instant);
  executor().schedule(wrap(runnable), seconds.getSeconds(), TimeUnit.SECONDS);
}

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

private void delayedSchedule(JobManager manager, Job job) {
  DateTime now = DateTime.now();
  // add one seconds to prevent the next time be the current time (now)
  DateTime next = cronExpr.nextTimeAfter(now.plusSeconds(1));
  Seconds seconds = Seconds.secondsBetween(now, next);
  ScheduledFuture future = manager.executor().schedule(job, seconds.getSeconds(), TimeUnit.SECONDS);
  manager.futureScheduled(job.id(), future);
}

代码示例来源:origin: hawkular/hawkular-metrics

private int getTTL(MetricId<?> metricId) {
  Integer ttl = dataRetentions.get(new DataRetentionKey(metricId));
  if (ttl == null) {
    ttl = dataRetentions.getOrDefault(new DataRetentionKey(metricId.getTenantId(), metricId.getType()),
        defaultTTL);
  } else {
    ttl = Duration.standardDays(ttl).toStandardSeconds().getSeconds();
  }
  return ttl;
}

代码示例来源:origin: org.actframework/act

private void delayedSchedule(JobManager manager, Job job) {
  DateTime now = DateTime.now();
  // add one seconds to prevent the next time be the current time (now)
  DateTime next = cronExpr.nextTimeAfter(now.plusSeconds(1));
  Seconds seconds = Seconds.secondsBetween(now, next);
  ScheduledFuture future = manager.executor().schedule(job, seconds.getSeconds(), TimeUnit.SECONDS);
  manager.futureScheduled(job.id(), future);
}

代码示例来源:origin: org.hawkular.metrics/hawkular-metrics-core-service

private int getTTL(MetricId<?> metricId) {
  Integer ttl = dataRetentions.get(new DataRetentionKey(metricId));
  if (ttl == null) {
    ttl = dataRetentions.getOrDefault(new DataRetentionKey(metricId.getTenantId(), metricId.getType()),
        defaultTTL);
  } else {
    ttl = Duration.standardDays(ttl).toStandardSeconds().getSeconds();
  }
  return ttl;
}

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

@Test
public void testJodaTimePeriod() throws ParseException {
  String periodText = "PT10m";
  Period period = new Period(periodText);
  int seconds = period.toStandardSeconds().getSeconds();
  Assert.assertEquals(600, seconds);
  Assert.assertEquals(60, period.toStandardSeconds().dividedBy(10).getSeconds());
}

相关文章