hudson.Util.getTimeSpanString()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(184)

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

Util.getTimeSpanString介绍

[英]Returns a human readable text of the time duration, for example "3 minutes 40 seconds". This version should be used for representing a duration of some activity (like build)
[中]返回持续时间的可读文本,例如“3分40秒”。此版本应用于表示某些活动(如构建)的持续时间

代码示例

代码示例来源:origin: jenkinsci/jenkins

/**
 * Returns a human readable presentation of how long this item is already in the queue.
 * E.g. something like '3 minutes 40 seconds'
 */
public String getInQueueForString() {
  long duration = System.currentTimeMillis() - this.inQueueSince;
  return Util.getTimeSpanString(duration);
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Human readable string of when this polling is started.
 */
public String getDuration() {
  return Util.getTimeSpanString(System.currentTimeMillis()-startTime);
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Get a human readable string representing strings like "xxx days ago",
 * which should be used to point to the occurrence of an event in the past.
 */
@Nonnull
public static String getPastTimeString(long duration) {
  return Messages.Util_pastTime(getTimeSpanString(duration));
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Returns a human-readable string representation of when this user was last active.
 */
public String getLastChangeTimeString() {
  if(lastChange==null)    return "N/A";
  long duration = new GregorianCalendar().getTimeInMillis()- ordinal();
  return Util.getTimeSpanString(duration);
}

代码示例来源:origin: jenkinsci/jenkins

public String getTimeSpanString() {
  return Util.getTimeSpanString(System.currentTimeMillis()-getLastModified());
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Gets the string that says how long the build took to run.
 */
public @Nonnull String getDurationString() {
  if (hasntStartedYet()) {
    return Messages.Run_NotStartedYet();
  } else if (isBuilding()) {
    return Messages.Run_InProgressDuration(
        Util.getTimeSpanString(System.currentTimeMillis()-startTime));
  }
  return Util.getTimeSpanString(duration);
}

代码示例来源:origin: jenkinsci/jenkins

if (waitBetweenRetries != 0) {
  sb.append(" waiting ");
  sb.append(Util.getTimeSpanString(Math.abs(waitBetweenRetries)));
  if (waitBetweenRetries < 0) {
    sb.append("-");
    sb.append(Util.getTimeSpanString(Math.abs(waitBetweenRetries) * (maxRetries + 1)));

代码示例来源:origin: jenkinsci/jenkins

public CauseOfBlockage getCauseOfBlockage() {
  long diff = timestamp.getTimeInMillis() - System.currentTimeMillis();
  if (diff >= 0)
    return CauseOfBlockage.fromMessage(Messages._Queue_InQuietPeriod(Util.getTimeSpanString(diff)));
  else
    return CauseOfBlockage.fromMessage(Messages._Queue_FinishedWaiting());
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Gets the clock difference in HTML string.
 */
@Override
public String toString() {
  if(-1000<diff && diff <1000)
    return Messages.ClockDifference_InSync();  // clock is in sync
  long abs = Math.abs(diff);
  String s = Util.getTimeSpanString(abs);
  if(diff<0)
    s = Messages.ClockDifference_Ahead(s);
  else
    s = Messages.ClockDifference_Behind(s);
  return s;
}

代码示例来源:origin: jenkinsci/jenkins

private boolean runPolling() {
  try {
    // to make sure that the log file contains up-to-date text,
    // don't do buffering.
    StreamTaskListener listener = new StreamTaskListener(getLogFile());
    try {
      PrintStream logger = listener.getLogger();
      long start = System.currentTimeMillis();
      logger.println("Started on "+ DateFormat.getDateTimeInstance().format(new Date()));
      boolean result = job().poll(listener).hasChanges();
      logger.println("Done. Took "+ Util.getTimeSpanString(System.currentTimeMillis()-start));
      if(result)
        logger.println("Changes found");
      else
        logger.println("No changes");
      return result;
    } catch (Error | RuntimeException e) {
      Functions.printStackTrace(e, listener.error("Failed to record SCM polling for " + job));
      LOGGER.log(Level.SEVERE,"Failed to record SCM polling for "+job,e);
      throw e;
    } finally {
      listener.close();
    }
  } catch (IOException e) {
    LOGGER.log(Level.SEVERE,"Failed to record SCM polling for "+job,e);
    return false;
  }
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Computes a human-readable text that shows the expected remaining time
 * until the build completes.
 */
public String getEstimatedRemainingTime() {
  long d = executableEstimatedDuration;
  if (d < 0) {
    return Messages.Executor_NotAvailable();
  }
  long eta = d - getElapsedTime();
  if (eta <= 0) {
    return Messages.Executor_NotAvailable();
  }
  return Util.getTimeSpanString(eta);
}

代码示例来源:origin: jenkinsci/jenkins

LOGGER.log(Level.FINE, "Directory {0} is only {1} old, so not deleting", new Object[] {dir, Util.getTimeSpanString(now-dir.lastModified())});
return false;

代码示例来源:origin: jenkinsci/jenkins

new Object[]{c.getName(), Util.getTimeSpanString(demandMilliseconds)});
  c.connect(false);
      new Object[]{c.getName(), Util.getTimeSpanString(idleMilliseconds)});
  c.disconnect(new OfflineCause.IdleOfflineCause());
} else {

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * Human readable string of when this polling is started.
 */
public String getDuration() {
  return Util.getTimeSpanString(System.currentTimeMillis()-startTime);
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * Returns a human readable presentation of how long this item is already in the queue.
 * E.g. something like '3 minutes 40 seconds'
 */
public String getInQueueForString() {
  long duration = System.currentTimeMillis() - this.inQueueSince;
  return Util.getTimeSpanString(duration);
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * Returns a human-readable string representation of when this user was last active.
 */
public String getLastChangeTimeString() {
  if(lastChange==null)    return "N/A";
  long duration = new GregorianCalendar().getTimeInMillis()- ordinal();
  return Util.getTimeSpanString(duration);
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * Get a human readable string representing strings like "xxx days ago",
 * which should be used to point to the occurrence of an event in the past.
 */
@Nonnull
public static String getPastTimeString(long duration) {
  return Messages.Util_pastTime(getTimeSpanString(duration));
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
 * Returns a human-readable string representation of when this user was last active.
 */
public String getLastChangeTimeString() {
  if(lastChange==null)    return "N/A";
  long duration = new GregorianCalendar().getTimeInMillis()- ordinal();
  return Util.getTimeSpanString(duration);
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * Gets the string that says how long the build took to run.
 */
public @Nonnull String getDurationString() {
  if (hasntStartedYet()) {
    return Messages.Run_NotStartedYet();
  } else if (isBuilding()) {
    return Messages.Run_InProgressDuration(
        Util.getTimeSpanString(System.currentTimeMillis()-startTime));
  }
  return Util.getTimeSpanString(duration);
}

代码示例来源:origin: jenkinsci/docker-plugin

/**
 * How long ago this will remain disabled by the system, e.g. "2 min 0 sec".
 */
public String getWhenReEnableBySystemString() {
  final long now = readTimeNowInNanoseconds();
  if (!getDisabledBySystem()) {
    return "";
  }
  final long howSoonInNanoseconds = nanotimeWhenReEnableBySystem - now;
  final long howSoonInMilliseconds = TimeUnit.NANOSECONDS.toMillis(howSoonInNanoseconds);
  return Util.getTimeSpanString(howSoonInMilliseconds);
}

相关文章

微信公众号

最新文章

更多