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

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

本文整理了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

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

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

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

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

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

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

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

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

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

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

  1. /**
  2. * Gets the string that says how long the build took to run.
  3. */
  4. public @Nonnull String getDurationString() {
  5. if (hasntStartedYet()) {
  6. return Messages.Run_NotStartedYet();
  7. } else if (isBuilding()) {
  8. return Messages.Run_InProgressDuration(
  9. Util.getTimeSpanString(System.currentTimeMillis()-startTime));
  10. }
  11. return Util.getTimeSpanString(duration);
  12. }

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

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

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

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

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

  1. /**
  2. * Gets the clock difference in HTML string.
  3. */
  4. @Override
  5. public String toString() {
  6. if(-1000<diff && diff <1000)
  7. return Messages.ClockDifference_InSync(); // clock is in sync
  8. long abs = Math.abs(diff);
  9. String s = Util.getTimeSpanString(abs);
  10. if(diff<0)
  11. s = Messages.ClockDifference_Ahead(s);
  12. else
  13. s = Messages.ClockDifference_Behind(s);
  14. return s;
  15. }

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

  1. private boolean runPolling() {
  2. try {
  3. // to make sure that the log file contains up-to-date text,
  4. // don't do buffering.
  5. StreamTaskListener listener = new StreamTaskListener(getLogFile());
  6. try {
  7. PrintStream logger = listener.getLogger();
  8. long start = System.currentTimeMillis();
  9. logger.println("Started on "+ DateFormat.getDateTimeInstance().format(new Date()));
  10. boolean result = job().poll(listener).hasChanges();
  11. logger.println("Done. Took "+ Util.getTimeSpanString(System.currentTimeMillis()-start));
  12. if(result)
  13. logger.println("Changes found");
  14. else
  15. logger.println("No changes");
  16. return result;
  17. } catch (Error | RuntimeException e) {
  18. Functions.printStackTrace(e, listener.error("Failed to record SCM polling for " + job));
  19. LOGGER.log(Level.SEVERE,"Failed to record SCM polling for "+job,e);
  20. throw e;
  21. } finally {
  22. listener.close();
  23. }
  24. } catch (IOException e) {
  25. LOGGER.log(Level.SEVERE,"Failed to record SCM polling for "+job,e);
  26. return false;
  27. }
  28. }

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

  1. /**
  2. * Computes a human-readable text that shows the expected remaining time
  3. * until the build completes.
  4. */
  5. public String getEstimatedRemainingTime() {
  6. long d = executableEstimatedDuration;
  7. if (d < 0) {
  8. return Messages.Executor_NotAvailable();
  9. }
  10. long eta = d - getElapsedTime();
  11. if (eta <= 0) {
  12. return Messages.Executor_NotAvailable();
  13. }
  14. return Util.getTimeSpanString(eta);
  15. }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  1. /**
  2. * Gets the string that says how long the build took to run.
  3. */
  4. public @Nonnull String getDurationString() {
  5. if (hasntStartedYet()) {
  6. return Messages.Run_NotStartedYet();
  7. } else if (isBuilding()) {
  8. return Messages.Run_InProgressDuration(
  9. Util.getTimeSpanString(System.currentTimeMillis()-startTime));
  10. }
  11. return Util.getTimeSpanString(duration);
  12. }

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

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

相关文章