Java 类org.apache.commons.lang.time.DurationFormatUtils 实例源码

项目:HCFCore    文件:KitsCommand.java   
private ItemStack titaniumKitGlass(Player player) {
    ItemStack stack = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 0, (byte) 14);
    ItemMeta meta = stack.getItemMeta();
    addGlow(stack);
    meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&4Titanium &7Kit"));
    List<String> lore = new ArrayList<String>();
    lore.add(ChatColor.translateAlternateColorCodes('&', "&7This is a kit contains:"));
    lore.add(ChatColor.translateAlternateColorCodes('&', "&fGod Diamond kit!"));
    lore.add("");
    lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &cPurchase the Titanium Rank from store.hcriots.net"));
    lore.add("");
    lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7CoolDown: &c3 Days"));
    if(cooldowns.containsKey(player.getUniqueId())) {
        if(cooldowns.get(player.getUniqueId()).containsKey("TitaniumKit")) {
            lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7Available in: &c" + DurationFormatUtils.formatDurationWords(cooldowns.get(player.getUniqueId()).get("TitaniumKit"), true, true)));
        } else {
            lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7Available in: &aNow"));
        }
    } else {
        lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7Available in: &aNow"));
    }
    meta.setLore(lore);
    stack.setItemMeta(meta);
    return stack;
}
项目:HCFCore    文件:KitsCommand.java   
private ItemStack diamondKitGlass(Player player) {
    ItemStack stack = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 0, (byte) 9);
    ItemMeta meta = stack.getItemMeta();
    addGlow(stack);
    meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&bDiamond &7Kit"));
    List<String> lore = new ArrayList<String>();
    lore.add(ChatColor.translateAlternateColorCodes('&', "&7This kit contains:"));
    lore.add(ChatColor.translateAlternateColorCodes('&', "&fGod Diamond kit with Looting!"));
    lore.add("");
    lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &cPurchase this from store.hcriots.net"));
    lore.add("");
    lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7CoolDown: &c3 Days"));
    if(cooldowns.containsKey(player.getUniqueId())) {
        if(cooldowns.get(player.getUniqueId()).containsKey("DiamondKit")) {
            lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7Available in: &c" + DurationFormatUtils.formatDurationWords(cooldowns.get(player.getUniqueId()).get("DiamondKit"), true, true)));
        } else {
            lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7Available in: &aNow"));
        }
    } else {
        lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7Available in: &aNow"));
    }
    meta.setLore(lore);
    stack.setItemMeta(meta);
    return stack;
}
项目:HCFCore    文件:KitsCommand.java   
private ItemStack bardKitGlass(Player player) {
    ItemStack stack = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 0, (byte) 4);
    ItemMeta meta = stack.getItemMeta();
    addGlow(stack);
    meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&eBard &7Kit"));
    List<String> lore = new ArrayList<String>();
    lore.add(ChatColor.translateAlternateColorCodes('&', "&7This kit contains:"));
    lore.add(ChatColor.translateAlternateColorCodes('&', "&fGod Bard kit with Bard Materials!"));
    lore.add("");
    lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &cPurchase this from store.hcriots.net"));
    lore.add("");
    lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7CoolDown: &c3 Days"));
    if(cooldowns.containsKey(player.getUniqueId())) {
        if(cooldowns.get(player.getUniqueId()).containsKey("BardKit")) {
            lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7Available in: &c" + DurationFormatUtils.formatDurationWords(cooldowns.get(player.getUniqueId()).get("BardKit"), true, true)));
        } else {
            lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7Available in: &aNow"));
        }
    } else {
        lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7Available in: &aNow"));
    }
    meta.setLore(lore);
    stack.setItemMeta(meta);
    return stack;
}
项目:HCFCore    文件:KitsCommand.java   
private ItemStack archerKitGlass(Player player) {
    ItemStack stack = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 0, (byte) 6);
    ItemMeta meta = stack.getItemMeta();
    addGlow(stack);
    meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&dArcher &7Kit"));
    List<String> lore = new ArrayList<String>();
    lore.add(ChatColor.translateAlternateColorCodes('&', "&7This kit contains:"));
    lore.add(ChatColor.translateAlternateColorCodes('&', "&fGod Archer kit with Archer Materials!"));
    lore.add("");
    lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &cPurchase this from store.hcriots.net"));
    lore.add("");
    lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7CoolDown: &c3 Days"));
    if(cooldowns.containsKey(player.getUniqueId())) {
        if(cooldowns.get(player.getUniqueId()).containsKey("ArcherKit")) {
            lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7Available in: &c" + DurationFormatUtils.formatDurationWords(cooldowns.get(player.getUniqueId()).get("ArcherKit"), true, true)));
        } else {
            lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7Available in: &aNow"));
        }
    } else {
        lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7Available in: &aNow"));
    }
    meta.setLore(lore);
    stack.setItemMeta(meta);
    return stack;
}
项目:HCFCore    文件:KitsCommand.java   
private ItemStack minerKitGlass(Player player) {
    ItemStack stack = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 0, (byte) 6);
    ItemMeta meta = stack.getItemMeta();
    addGlow(stack);
    meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&9Miner &7Kit"));
    List<String> lore = new ArrayList<String>();
    lore.add(ChatColor.translateAlternateColorCodes('&', "&7This kit contains:"));
    lore.add(ChatColor.translateAlternateColorCodes('&', "&fGod Miner Set with Diamond Pickaxe and Anvils!"));
    lore.add("");
    lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &cPurchase this from store.hcriots.net"));
    lore.add("");
    lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7CoolDown: &c3 Days"));
    if(cooldowns.containsKey(player.getUniqueId())) {
        if(cooldowns.get(player.getUniqueId()).containsKey("ArcherKit")) {
            lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7Available in: &c" + DurationFormatUtils.formatDurationWords(cooldowns.get(player.getUniqueId()).get("ArcherKit"), true, true)));
        } else {
            lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7Available in: &aNow"));
        }
    } else {
        lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7Available in: &aNow"));
    }
    meta.setLore(lore);
    stack.setItemMeta(meta);
    return stack;
}
项目:HCFCore    文件:KitsCommand.java   
private ItemStack starterKitGlass(Player player) {
    ItemStack stack = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 0, (byte) 13);
    ItemMeta meta = stack.getItemMeta();
    addGlow(stack);
    meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&fStarter &7Kit"));
    List<String> lore = new ArrayList<String>();
    lore.add(ChatColor.translateAlternateColorCodes('&', "&7This kit contains:"));
    lore.add(ChatColor.translateAlternateColorCodes('&', "&fLeather Set with an Iron Sword, Iron Pickaxe, and Food!"));
    lore.add("");
    lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &cPurchase this from store.hcriots.net"));
    lore.add("");
    lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7CoolDown: &c3 Days"));
    if(cooldowns.containsKey(player.getUniqueId())) {
        if(cooldowns.get(player.getUniqueId()).containsKey("StarterKit")) {
            lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7Available in: &c" + DurationFormatUtils.formatDurationWords(cooldowns.get(player.getUniqueId()).get("StarterKit"), true, true)));
        } else {
            lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7Available in: &aNow"));
        }
    } else {
        lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7Available in: &aNow"));
    }
    meta.setLore(lore);
    stack.setItemMeta(meta);
    return stack;
}
项目:engerek    文件:CertCaseOrWorkItemDto.java   
private String computeDeadlineAsString(PageBase page) {
    XMLGregorianCalendar deadline = certCase.getCurrentStageDeadline();

    if (deadline == null) {
        return "";
    } else {
        long delta = XmlTypeConverter.toMillis(deadline) - System.currentTimeMillis();

        // round to hours; we always round down
        long precision = 3600000L;      // 1 hour
        if (Math.abs(delta) > precision) {
            delta = (delta / precision) * precision;
        }

        //todo i18n
        if (delta > 0) {
            return PageBase.createStringResourceStatic(page, "PageCert.in", DurationFormatUtils.formatDurationWords(delta, true, true)).getString();
        } else if (delta < 0) {
            return PageBase.createStringResourceStatic(page, "PageCert.ago", DurationFormatUtils.formatDurationWords(-delta, true, true)).getString();
        } else {
            return page.getString("PageCert.now");
        }
    }
}
项目:dsworkbench    文件:SupportsModel.java   
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
    Defense elem = entries.get(rowIndex);
    switch (columnIndex) {
        case 0:
            return elem.getSupporter();
        case 1:
            return elem.getTarget();
        case 2:
            return new Date(elem.getBestSendTime());
        case 3:
            return new Date(elem.getWorstSendTime());
        case 4:

            long sendTime = elem.getBestSendTime();
            if (sendTime < System.currentTimeMillis()) {//if best in past, take worst
                sendTime = elem.getWorstSendTime();
            }
            long t = sendTime - System.currentTimeMillis();
            t = (t <= 0) ? 0 : t;
            return DurationFormatUtils.formatDuration(t, "HHH:mm:ss.SSS", true);
        default:
            return elem.isTransferredToBrowser();
    }
}
项目:midpoint    文件:CertCaseOrWorkItemDto.java   
private String computeDeadlineAsString(PageBase page) {
    XMLGregorianCalendar deadline = certCase.getCurrentStageDeadline();

    if (deadline == null) {
        return "";
    } else {
        long delta = XmlTypeConverter.toMillis(deadline) - System.currentTimeMillis();

        // round to hours; we always round down
        long precision = 3600000L;      // 1 hour
        if (Math.abs(delta) > precision) {
            delta = (delta / precision) * precision;
        }

        //todo i18n
        if (delta > 0) {
            return PageBase.createStringResourceStatic(page, "PageCert.in", DurationFormatUtils.formatDurationWords(delta, true, true)).getString();
        } else if (delta < 0) {
            return PageBase.createStringResourceStatic(page, "PageCert.ago", DurationFormatUtils.formatDurationWords(-delta, true, true)).getString();
        } else {
            return page.getString("PageCert.now");
        }
    }
}
项目:midpoint    文件:CertCaseOrWorkItemDto.java   
private String computeDeadlineAsString(PageBase page) {
    XMLGregorianCalendar deadline = certCase.getCurrentStageDeadline();

    if (deadline == null) {
        return "";
    } else {
        long delta = XmlTypeConverter.toMillis(deadline) - System.currentTimeMillis();

        // round to hours; we always round down
        long precision = 3600000L;      // 1 hour
        if (Math.abs(delta) > precision) {
            delta = (delta / precision) * precision;
        }

        //todo i18n
        if (delta > 0) {
            return PageBase.createStringResourceStatic(page, "PageCert.in", DurationFormatUtils.formatDurationWords(delta, true, true)).getString();
        } else if (delta < 0) {
            return PageBase.createStringResourceStatic(page, "PageCert.ago", DurationFormatUtils.formatDurationWords(-delta, true, true)).getString();
        } else {
            return page.getString("PageCert.now");
        }
    }
}
项目:pdb    文件:AbstractBatch.java   
/**
 * Destroys this batch.
 */
public void destroy() {
    logger.trace("{} - Destroy called on Batch", name);
    scheduler.shutdown();

    try {
        if (!scheduler.awaitTermination(maxAwaitTimeShutdown, TimeUnit.MILLISECONDS)) {
            logger.warn(
                    "Could not terminate batch within {}. Forcing shutdown.",
                    DurationFormatUtils.formatDurationWords(
                            maxAwaitTimeShutdown,
                            true,
                            true
                    )
            );
            scheduler.shutdownNow();
        }
    } catch (final InterruptedException e) {
        Thread.currentThread().interrupt();
        logger.debug("Interrupted while waiting.", e);
    }

    flush();
}
项目:iaf    文件:TibcoUtils.java   
protected static String getQueueFirstMessageAgeAsString(Session jSession,
        String queueName, long currentTime) {
    try {
        long age = getQueueFirstMessageAge(jSession, queueName, null,
                currentTime, false);
        if (age == -2) {
            return "??";
        } else if (age == -1) {
            return null;
        } else {
            return DurationFormatUtils.formatDuration(age, "ddd-HH:mm:ss");
        }
    } catch (JMSException e) {
        return "?";
    }
}
项目:iaf    文件:Misc.java   
public static String getAge(long value) {
    long currentTime = (new Date()).getTime();
    long age = currentTime - value;
    String ageString = DurationFormatUtils.formatDuration(age, "d") + "d";
    if ("0d".equals(ageString)) {
        ageString = DurationFormatUtils.formatDuration(age, "H") + "h";
        if ("0h".equals(ageString)) {
            ageString = DurationFormatUtils.formatDuration(age, "m") + "m";
            if ("0m".equals(ageString)) {
                ageString = DurationFormatUtils.formatDuration(age, "s") + "s";
                if ("0s".equals(ageString)) {
                    ageString = age + "ms";
                }
            }
        }
    }
    return ageString;
}
项目:lakeside-java    文件:StopWatch.java   
/**
 * output as:
 * 551          150         1000        0:00:01.701
 * step1(ms)    step2(ms)   step3(ms)   total duration
 */
@Override
public String toString() {
    long currentTimeMillis = System.currentTimeMillis();
    if(stops!=null && stops.size()>0){
        List<Long> durationList = new ArrayList<Long>();
        long last = this.startTime;
        for(int i=0;i<stops.size();i++){
            long cur = stops.get(i);
durationList.add(cur - last);
last = cur;
        }
        if (this.running) {
durationList.add(currentTimeMillis - last);
     } else {
        durationList.add(this.stopTime - last);
     }

        return StringUtils.join(durationList, "\t")+"\t"+DurationFormatUtils.formatDurationHMS(getTime(currentTimeMillis));
    }else{
        return DurationFormatUtils.formatDurationHMS(getTime(currentTimeMillis));
    }
}
项目:Open-DM    文件:PopulateDmDb.java   
private void displayStats(long insertedCnt) {
    float percentComplete = (float) insertedCnt / (float) rowCnt;
    long now = System.currentTimeMillis();
    long elapsedTime = now - startTime;
    long timeRemaining = ((long) (((float) (now - startTime)) / percentComplete)) - elapsedTime;
    String elapsedTimeStr = DurationFormatUtils.formatDurationWords(elapsedTime, true, true);
    String timeRemainingStr = DurationFormatUtils.formatDurationWords(timeRemaining, true,
                                                                      true);

    System.out.println("Inserted " + insertedCnt + " rows (" + readyToFindCnt + " readyToFind, "
            + readyToProcessCnt + " readyToProcess, " + readyToPostProcessCnt
            + " readyToPostProcess) in " + elapsedTimeStr + ".  "
            + ((int) (percentComplete * 100)) + " % complete, " + timeRemainingStr
            + " remaining.");
}
项目:osc-core    文件:ServerUtil.java   
/**
 * Returns a thread which executes the provided command if the system clock moves forward or backwards by the
 * threshold specified.
 *
 * @param timeChangeCommand
 *            the command to run when system clock is changed
 * @param timeChangeThreshold
 *            the time difference in millisecs that the caller can adjust for, if the time changes by
 *            more than this amount, the time change command will be executed.
 * @param sleepInterval
 *            the amount of time the thread sleeps before it checks to see if system clock was changed
 *
 * @return the thread which the caller can decide to start
 */
public static Thread getTimeMonitorThread(final TimeChangeCommand timeChangeCommand, final long timeChangeThreshold,
        final long sleepInterval) {
    Runnable timeMonitorThread = new Runnable() {

        private long previousTime = new Date().getTime();

        @Override
        public void run() {
            while (true) {
                long currentTime = new Date().getTime();
                long timeDifference = currentTime - (this.previousTime + sleepInterval);
                if (timeDifference >= timeChangeThreshold || timeDifference <= -timeChangeThreshold) {
                    String timeDifferenceString = DurationFormatUtils.formatDuration(Math.abs(timeDifference),
                            "d 'Days' H 'Hours' m 'Minutes' s 'Seconds'");
                    log.warn(String.format(
                            "System Time change detected. Time shift: %s Current Time: %s  Previous Time: %s",
                            timeDifferenceString, new Date(currentTime), new Date(this.previousTime)));
                    timeChangeCommand.execute(timeDifference);
                }
                this.previousTime = currentTime;

                try {
                    Thread.sleep(sleepInterval);
                } catch (InterruptedException e) {
                    log.info("Time monitor thread interrupted. Ignoring...");
                }
            }
        }
    };

    return new Thread(timeMonitorThread, "Time-Monitor-Thread");
}
项目:hadoop    文件:FsDatasetCache.java   
private boolean shouldDefer() {
  /* If revocationTimeMs == 0, this is an immediate uncache request.
   * No clients were anchored at the time we made the request. */
  if (revocationTimeMs == 0) {
    return false;
  }
  /* Let's check if any clients still have this block anchored. */
  boolean anchored =
    !dataset.datanode.getShortCircuitRegistry().
        processBlockMunlockRequest(key);
  if (!anchored) {
    LOG.debug("Uncaching {} now that it is no longer in use " +
        "by any clients.", key);
    return false;
  }
  long delta = revocationTimeMs - Time.monotonicNow();
  if (delta < 0) {
    LOG.warn("Forcibly uncaching {} after {} " +
        "because client(s) {} refused to stop using it.", key,
        DurationFormatUtils.formatDurationHMS(revocationTimeMs),
        dataset.datanode.getShortCircuitRegistry().getClientNames(key));
    return false;
  }
  LOG.info("Replica {} still can't be uncached because some " +
      "clients continue to use it.  Will wait for {}", key,
      DurationFormatUtils.formatDurationHMS(delta));
  return true;
}
项目:aliyun-oss-hadoop-fs    文件:FsDatasetCache.java   
private boolean shouldDefer() {
  /* If revocationTimeMs == 0, this is an immediate uncache request.
   * No clients were anchored at the time we made the request. */
  if (revocationTimeMs == 0) {
    return false;
  }
  /* Let's check if any clients still have this block anchored. */
  boolean anchored =
    !dataset.datanode.getShortCircuitRegistry().
        processBlockMunlockRequest(key);
  if (!anchored) {
    LOG.debug("Uncaching {} now that it is no longer in use " +
        "by any clients.", key);
    return false;
  }
  long delta = revocationTimeMs - Time.monotonicNow();
  if (delta < 0) {
    LOG.warn("Forcibly uncaching {} after {} " +
        "because client(s) {} refused to stop using it.", key,
        DurationFormatUtils.formatDurationHMS(revocationTimeMs),
        dataset.datanode.getShortCircuitRegistry().getClientNames(key));
    return false;
  }
  LOG.info("Replica {} still can't be uncached because some " +
      "clients continue to use it.  Will wait for {}", key,
      DurationFormatUtils.formatDurationHMS(delta));
  return true;
}
项目:big-c    文件:FsDatasetCache.java   
private boolean shouldDefer() {
  /* If revocationTimeMs == 0, this is an immediate uncache request.
   * No clients were anchored at the time we made the request. */
  if (revocationTimeMs == 0) {
    return false;
  }
  /* Let's check if any clients still have this block anchored. */
  boolean anchored =
    !dataset.datanode.getShortCircuitRegistry().
        processBlockMunlockRequest(key);
  if (!anchored) {
    LOG.debug("Uncaching {} now that it is no longer in use " +
        "by any clients.", key);
    return false;
  }
  long delta = revocationTimeMs - Time.monotonicNow();
  if (delta < 0) {
    LOG.warn("Forcibly uncaching {} after {} " +
        "because client(s) {} refused to stop using it.", key,
        DurationFormatUtils.formatDurationHMS(revocationTimeMs),
        dataset.datanode.getShortCircuitRegistry().getClientNames(key));
    return false;
  }
  LOG.info("Replica {} still can't be uncached because some " +
      "clients continue to use it.  Will wait for {}", key,
      DurationFormatUtils.formatDurationHMS(delta));
  return true;
}
项目:LLApp    文件:MikyouCountDownTimer.java   
@Override
public void onTick(long l) {
    if (l > 0) {
        mTimeStr = DurationFormatUtils.formatDuration(l, mTimePattern);
        //这是apache中的common的lang包中DurationFormatUtils类中的formatDuration,通过传入
        //一个时间格式就会自动将倒计时转换成相应的mTimePattern的样式(HH:mm:ss或dd天HH时mm分ss秒)
        setBackgroundSpan(mTimeStr);
    }
}
项目:engerek    文件:PageTasks.java   
private String createScheduledToRunAgain(IModel<TaskDto> taskModel) {
      TaskDto task = taskModel.getObject();
boolean runnable = task.getRawExecutionStatus() == TaskExecutionStatus.RUNNABLE;
      Long scheduledAfter = task.getScheduledToStartAgain();
Long retryAfter = runnable ? task.getRetryAfter() : null;

      if (scheduledAfter == null) {
          if (retryAfter == null || retryAfter <= 0) {
              return "";
          }
      } else if (scheduledAfter == TaskDto.NOW) { // TODO what about retryTime?
          return getString(runnable ? "pageTasks.now" : "pageTasks.nowForNotRunningTasks");
      } else if (scheduledAfter == TaskDto.RUNS_CONTINUALLY) {  // retryTime is probably null here
          return getString("pageTasks.runsContinually");
      } else if (scheduledAfter == TaskDto.ALREADY_PASSED && retryAfter == null) {
          return getString(runnable ? "pageTasks.alreadyPassed" : "pageTasks.alreadyPassedForNotRunningTasks");
      }

      long displayTime;
      boolean displayAsRetry;
      if (retryAfter != null && retryAfter > 0 && (scheduledAfter == null || scheduledAfter < 0 || retryAfter < scheduledAfter)) {
        displayTime = retryAfter;
        displayAsRetry = true;
} else {
        displayTime = scheduledAfter;
        displayAsRetry = false;
}

String key;
      if (runnable) {
        key = displayAsRetry ? "pageTasks.retryIn" : "pageTasks.in";
} else {
        key = "pageTasks.inForNotRunningTasks";
}

      //todo i18n
      return PageBase.createStringResourceStatic(this, key, DurationFormatUtils.formatDurationWords(displayTime, true, true)).getString();
  }
项目:engerek    文件:PageTasks.java   
private String createLastCheckInTime(IModel<NodeDto> nodeModel) {
    NodeDto node = nodeModel.getObject();
    Long time = node.getLastCheckInTime();
    if (time == null || time == 0) {
        return "";
    }

    //todo i18n
    return DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - time, true, true)
            + " ago";
}
项目:antsdb    文件:Validator.java   
private void report() {
    long duration = this.endTime - this.startTime;
       if (duration == 0) {
           return;
       }
    println("errors found: %s", this.errors);
    println("duration: %s", DurationFormatUtils.formatDurationHMS(duration));
    println("speed: %d/sec", this.count * 1000 / duration);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:FsDatasetCache.java   
private boolean shouldDefer() {
  /* If revocationTimeMs == 0, this is an immediate uncache request.
   * No clients were anchored at the time we made the request. */
  if (revocationTimeMs == 0) {
    return false;
  }
  /* Let's check if any clients still have this block anchored. */
  boolean anchored =
    !dataset.datanode.getShortCircuitRegistry().
        processBlockMunlockRequest(key);
  if (!anchored) {
    LOG.debug("Uncaching {} now that it is no longer in use " +
        "by any clients.", key);
    return false;
  }
  long delta = revocationTimeMs - Time.monotonicNow();
  if (delta < 0) {
    LOG.warn("Forcibly uncaching {} after {} " +
        "because client(s) {} refused to stop using it.", key,
        DurationFormatUtils.formatDurationHMS(revocationTimeMs),
        dataset.datanode.getShortCircuitRegistry().getClientNames(key));
    return false;
  }
  LOG.info("Replica {} still can't be uncached because some " +
      "clients continue to use it.  Will wait for {}", key,
      DurationFormatUtils.formatDurationHMS(delta));
  return true;
}
项目:statecharts    文件:SimulationView.java   
protected void updateTimestamp(long timestamp) {
    String formatDurationHMS = DurationFormatUtils.formatDuration(timestamp,
            (timestamp == 0 ? "--:--:--.---" : "HH:mm:ss.SSS"), true);
    timeLabel.setText(formatDurationHMS);
    String time = getReadableSimulationTime(timestamp);
    boolean isValidTime = time != null || (time != null && !time.isEmpty()) || timestamp != 0;
    timeIconLabel.setVisible(isValidTime);
    if (isValidTime) {
        timeLabel.setToolTipText("Simulation running since " + time);
        timeLabel.getParent().getParent().layout(); // layout all time-relevant components
    }
}
项目:statecharts    文件:SimulationView.java   
protected String getReadableSimulationTime(long timestamp) {
    long days = TimeUnit.MILLISECONDS.toDays(timestamp);
    long hours = TimeUnit.MILLISECONDS.toHours(timestamp);
    long minutes = TimeUnit.MILLISECONDS.toMinutes(timestamp);
    long seconds = TimeUnit.MILLISECONDS.toSeconds(timestamp);
    return DurationFormatUtils
            .formatDuration(timestamp,
                    (days > 0 ? "dd 'days '" : "") + (hours > 0 ? "HH 'hours '" : "")
                            + (minutes > 0 ? "mm 'minutes '" : "") + (seconds > 0 ? "ss 'seconds '" : ""),
                    false);

}
项目:dsworkbench    文件:FarmTableModel.java   
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
    FarmInformation elem = (FarmInformation) FarmManager.getSingleton().getAllElements().get(rowIndex);
    switch (columnIndex) {
        case 0:
            return elem.getStatus();
        case 1:
            return elem.isResourcesFoundInLastReport();
        case 2:
            return new Date(elem.getLastReport());
        case 3:
            return elem.getVillage().getShortName();
        case 4:
            return elem.getWallLevel();
        case 5:
            return elem.getStorageStatus();
        case 6:
            long t = elem.getRuntimeInformation();
            t = (t <= 0) ? 0 : t;
            if (t == 0) {
                return "Keine Truppen unterwegs";
            }
            return DurationFormatUtils.formatDuration(t, "HH:mm:ss", true);
        case 7:
            return elem.getLastResult();
        default:
            return elem.getCorrectionFactor();
    }
}
项目:FlexMap    文件:FsDatasetCache.java   
private boolean shouldDefer() {
  /* If revocationTimeMs == 0, this is an immediate uncache request.
   * No clients were anchored at the time we made the request. */
  if (revocationTimeMs == 0) {
    return false;
  }
  /* Let's check if any clients still have this block anchored. */
  boolean anchored =
    !dataset.datanode.getShortCircuitRegistry().
        processBlockMunlockRequest(key);
  if (!anchored) {
    LOG.debug("Uncaching {} now that it is no longer in use " +
        "by any clients.", key);
    return false;
  }
  long delta = revocationTimeMs - Time.monotonicNow();
  if (delta < 0) {
    LOG.warn("Forcibly uncaching {} after {} " +
        "because client(s) {} refused to stop using it.", key,
        DurationFormatUtils.formatDurationHMS(revocationTimeMs),
        dataset.datanode.getShortCircuitRegistry().getClientNames(key));
    return false;
  }
  LOG.info("Replica {} still can't be uncached because some " +
      "clients continue to use it.  Will wait for {}", key,
      DurationFormatUtils.formatDurationHMS(delta));
  return true;
}
项目:artifactory    文件:WicketAddonsImpl.java   
@Override
public Label getUptimeLabel(String wicketId) {
    long uptime = ContextHelper.get().getUptime();
    String uptimeStr = DurationFormatUtils.formatDuration(uptime, "d'd' H'h' m'm' s's'");
    Label uptimeLabel = new Label(wicketId, uptimeStr);
    //Only show uptime for admins
    if (!ContextHelper.get().getAuthorizationService().isAdmin()) {
        uptimeLabel.setVisible(false);
    }
    return uptimeLabel;
}
项目:gerbil    文件:InitialIndexTool.java   
public static void main(String[] args) throws GerbilException, IOException {
    Indexer index = new Indexer(OUTPUT_FOLDER);
    SimpleDateFormat format = new SimpleDateFormat();
    Date start = Calendar.getInstance().getTime();
    LOGGER.info("Start indexing at {}", format.format(start));
    indexFolder(index, args[0]);
    index.close();
    Date end = Calendar.getInstance().getTime();
    LOGGER.info("Indexing finished at {}", format.format(end));
    LOGGER.info("Indexing took: "
            + DurationFormatUtils.formatDurationHMS(end.getTime()
                    - start.getTime()));
}
项目:gerbil    文件:DBpediaEntityCheckIndexTool.java   
public static void main(String[] args) throws GerbilException, IOException {
    Indexer index = Indexer.create(OUTPUT_FOLDER);
    SimpleDateFormat format = new SimpleDateFormat();
    Date start = Calendar.getInstance().getTime();
    LOGGER.info("Start indexing at {}", format.format(start));
    indexFolder(index, INPUT_FOLDER);
    index.close();
    Date end = Calendar.getInstance().getTime();
    LOGGER.info("Indexing finished at {}", format.format(end));
    LOGGER.info("Indexing took: " + DurationFormatUtils.formatDurationHMS(end.getTime() - start.getTime()));
}
项目:midpoint    文件:PageTasks.java   
private String createScheduledToRunAgain(IModel<TaskDto> taskModel) {
      TaskDto task = taskModel.getObject();
boolean runnable = task.getRawExecutionStatus() == TaskExecutionStatus.RUNNABLE;
      Long scheduledAfter = task.getScheduledToStartAgain();
Long retryAfter = runnable ? task.getRetryAfter() : null;

      if (scheduledAfter == null) {
          if (retryAfter == null || retryAfter <= 0) {
              return "";
          }
      } else if (scheduledAfter == TaskDto.NOW) { // TODO what about retryTime?
          return getString(runnable ? "pageTasks.now" : "pageTasks.nowForNotRunningTasks");
      } else if (scheduledAfter == TaskDto.RUNS_CONTINUALLY) {  // retryTime is probably null here
          return getString("pageTasks.runsContinually");
      } else if (scheduledAfter == TaskDto.ALREADY_PASSED && retryAfter == null) {
          return getString(runnable ? "pageTasks.alreadyPassed" : "pageTasks.alreadyPassedForNotRunningTasks");
      }

      long displayTime;
      boolean displayAsRetry;
      if (retryAfter != null && retryAfter > 0 && (scheduledAfter == null || scheduledAfter < 0 || retryAfter < scheduledAfter)) {
        displayTime = retryAfter;
        displayAsRetry = true;
} else {
        displayTime = scheduledAfter;
        displayAsRetry = false;
}

String key;
      if (runnable) {
        key = displayAsRetry ? "pageTasks.retryIn" : "pageTasks.in";
} else {
        key = "pageTasks.inForNotRunningTasks";
}

      //todo i18n
      return PageBase.createStringResourceStatic(this, key, DurationFormatUtils.formatDurationWords(displayTime, true, true)).getString();
  }
项目:midpoint    文件:PageTasks.java   
private String createLastCheckInTime(IModel<NodeDto> nodeModel) {
    NodeDto node = nodeModel.getObject();
    Long time = node.getLastCheckInTime();
    if (time == null || time == 0) {
        return "";
    }

    //todo i18n
    return DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - time, true, true)
            + " ago";
}
项目:eclipse-timekeeper    文件:WorkWeekView.java   
private void updateStatus() {
    ITask activeTask = TasksUi.getTaskActivityManager().getActiveTask();
    if (activeTask == null) {
        statusLabel.setText("");
    } else if (TimekeeperUiPlugin.getDefault().isIdle()) {
        statusLabel.setText("Idle since " +
                timeFormat.format(TimekeeperUiPlugin.getDefault().getIdleSince()));
        // do not refresh with an editor active, that would deactivate the
        // editor and lose focus
        if (!viewer.isCellEditorActive()) {
            viewer.refresh(activeTask);
            viewer.refresh(contentProvider.getParent(activeTask));
            viewer.refresh(WeekViewContentProvider.WEEKLY_SUMMARY);
        }
    } else if (getActiveTime() > 0) {
        long activeTime = getActiveTime();
        LocalDateTime activeSince = TimekeeperUiPlugin.getDefault().getActiveSince();
        statusLabel.setText(MessageFormat.format("Active since {0}, {1} elapsed", timeFormat.format(activeSince),
                DurationFormatUtils.formatDurationWords(activeTime, true, true)));
        // do not refresh with an editor active, that would deactivate the
        // editor and lose focus
        if (!viewer.isCellEditorActive()) {
            viewer.refresh(activeTask);
            viewer.refresh(contentProvider.getParent(activeTask));
            viewer.refresh(WeekViewContentProvider.WEEKLY_SUMMARY);
        }
    }

}
项目:eclipse-timekeeper    文件:WorkWeekView.java   
/**
 * Creates a table column for the given weekday and installs editing support
 *
 * @param weekday
 *            the day of the week, starting from 0
 */
private void createTimeColumn(int weekday) {
    TreeViewerColumn column = createTableViewerColumn("-", TIME_COLUMN_WIDTH, 1 + weekday);
    column.getColumn().setAlignment(SWT.RIGHT);
    column.setEditingSupport(new TimeEditingSupport((TreeViewer) column.getViewer(), contentProvider, weekday));
    column.setLabelProvider(new TimeColumnLabelProvider(contentProvider) {

        @Override
        public String getText(Object element) {
            // Use modern formatting
            long seconds = 0;
            LocalDate date = contentProvider.getFirstDayOfWeek().plusDays(weekday);
            if (element instanceof String) {
                seconds = getSum(contentProvider.getFiltered(), date, (String) element);
            } else if (element instanceof ITask) {
                AbstractTask task = (AbstractTask) element;
                TrackedTask trackedTask = TimekeeperPlugin.getDefault().getTask(task);
                if (trackedTask != null) {
                    seconds = trackedTask.getDuration(contentProvider.getDate(weekday)).getSeconds();
                }
            } else if (element instanceof WeeklySummary) {
                seconds = getSum(contentProvider.getFiltered(), date);
            } else if (element instanceof Activity) {
                seconds = ((Activity) element).getDuration(date).getSeconds();
            }
            if (seconds > 0) {
                return DurationFormatUtils.formatDuration(seconds * 1000, "H:mm", true);
            }
            return "";
        }
    });
}
项目:eclipse-timekeeper    文件:WorkWeekView.java   
private String getFormattedPeriod(long seconds) {
    if (seconds > 0) {
        return DurationFormatUtils.formatDuration(seconds * 1000, "H:mm", true);
    }
    // TODO: Fix dates with no entries "0:00"
    return "";
}
项目:midpoint    文件:PageTasks.java   
private String createScheduledToRunAgain(IModel<TaskDto> taskModel) {
      TaskDto task = taskModel.getObject();
boolean runnable = task.getRawExecutionStatus() == TaskExecutionStatus.RUNNABLE;
      Long scheduledAfter = task.getScheduledToStartAgain();
Long retryAfter = runnable ? task.getRetryAfter() : null;

      if (scheduledAfter == null) {
          if (retryAfter == null || retryAfter <= 0) {
              return "";
          }
      } else if (scheduledAfter == TaskDto.NOW) { // TODO what about retryTime?
          return getString(runnable ? "pageTasks.now" : "pageTasks.nowForNotRunningTasks");
      } else if (scheduledAfter == TaskDto.RUNS_CONTINUALLY) {  // retryTime is probably null here
          return getString("pageTasks.runsContinually");
      } else if (scheduledAfter == TaskDto.ALREADY_PASSED && retryAfter == null) {
          return getString(runnable ? "pageTasks.alreadyPassed" : "pageTasks.alreadyPassedForNotRunningTasks");
      }

      long displayTime;
      boolean displayAsRetry;
      if (retryAfter != null && retryAfter > 0 && (scheduledAfter == null || scheduledAfter < 0 || retryAfter < scheduledAfter)) {
        displayTime = retryAfter;
        displayAsRetry = true;
} else {
        displayTime = scheduledAfter;
        displayAsRetry = false;
}

String key;
      if (runnable) {
        key = displayAsRetry ? "pageTasks.retryIn" : "pageTasks.in";
} else {
        key = "pageTasks.inForNotRunningTasks";
}

      //todo i18n
      return PageBase.createStringResourceStatic(this, key, DurationFormatUtils.formatDurationWords(displayTime, true, true)).getString();
  }
项目:midpoint    文件:PageTasks.java   
private String createLastCheckInTime(IModel<NodeDto> nodeModel) {
    NodeDto node = nodeModel.getObject();
    Long time = node.getLastCheckInTime();
    if (time == null || time == 0) {
        return "";
    }

    //todo i18n
    return DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - time, true, true)
            + " ago";
}
项目:CadalWorkspace    文件:Master.java   
private void endOutput() {
    long endTime = System.currentTimeMillis();
    System.out.printf("######## Output finished: %1$tY-%1$tb-%1$td %1$tT %tZ\n", endTime);
    System.out.println("######## Elapsed output time: "
        + DurationFormatUtils.formatPeriod(outputStartTime, endTime, "H:m:s") + " (h:m:s)");
    System.out.println("######## Total elapsed time: "
        + DurationFormatUtils.formatPeriod(startTime, endTime, "H:m:s") + " (h:m:s)");
}
项目:CadalWorkspace    文件:Master.java   
private void endOutput() {
    long endTime = System.currentTimeMillis();
    System.out.printf("######## Output finished: %1$tY-%1$tb-%1$td %1$tT %tZ\n", endTime);
    System.out.println("######## Elapsed output time: "
        + DurationFormatUtils.formatPeriod(outputStartTime, endTime, "H:m:s") + " (h:m:s)");
    System.out.println("######## Total elapsed time: "
        + DurationFormatUtils.formatPeriod(startTime, endTime, "H:m:s") + " (h:m:s)");
}