/** * <p> * Gets a summary of the time that the stopwatch recorded as a string. * </p> * * <p> * The format used is ISO8601-like, <i>hours</i>:<i>minutes</i>:<i>seconds</i>.<i>milliseconds</i>. * </p> * * @return the time as a String */ public String toString() { return DurationFormatUtils.formatDurationHMS(getTime()); }
/** * <p>Formats the time gap as a string.</p> * * <p>The format used is ISO8601-like: * <i>H</i>:<i>m</i>:<i>s</i>.<i>S</i>.</p> * * @param durationMillis the duration to format * @return the time as a String */ public static String formatDurationHMS(long durationMillis) { return formatDuration(durationMillis, "H:mm:ss.SSS"); }
/** * <p>Formats the time gap as a string.</p> * * <p>The format used is the ISO8601 period format.</p> * * @param startMillis the start of the duration to format * @param endMillis the end of the duration to format * @return the time as a String */ public static String formatPeriodISO(long startMillis, long endMillis) { return formatPeriod(startMillis, endMillis, ISO_EXTENDED_FORMAT_PATTERN, false, TimeZone.getDefault()); }
public static String formatDuration(long timeInMiliseconds) { return DurationFormatUtils.formatDurationWords(timeInMiliseconds, true, true); }
private void displayRuntimeInfo(CommandSender sender, RuntimeMXBean runtimeBean) { long uptime = runtimeBean.getUptime(); String uptimeFormat = DurationFormatUtils.formatDurationWords(uptime, false, false); displayMemoryInfo(sender, Runtime.getRuntime()); // runtime specific sendMessage(sender, "Uptime", uptimeFormat); sendMessage(sender, "Arguments", runtimeBean.getInputArguments().toString()); sendMessage(sender, "Classpath", runtimeBean.getClassPath()); sendMessage(sender, "Library path", runtimeBean.getLibraryPath()); }
/** * <p> * Gets a summary of the split time that the stopwatch recorded as a string. * </p> * * <p> * The format used is ISO8601-like, <i>hours</i>:<i>minutes</i>:<i>seconds</i>.<i>milliseconds</i>. * </p> * * @return the split time as a String * @since 2.1 */ public String toSplitString() { return DurationFormatUtils.formatDurationHMS(getSplitTime()); }
/** * <p>Formats the time gap as a string.</p> * * <p>The format used is the ISO8601 period format.</p> * * <p>This method formats durations using the days and lower fields of the * ISO format pattern, such as P7D6TH5M4.321S.</p> * * @param durationMillis the duration to format * @return the time as a String */ public static String formatDurationISO(long durationMillis) { return formatDuration(durationMillis, ISO_EXTENDED_FORMAT_PATTERN, false); }
/** * <p>Formats the time gap as a string, using the specified format. * Padding the left hand side of numbers with zeroes is optional. * * @param startMillis the start of the duration * @param endMillis the end of the duration * @param format the way in which to format the duration * @return the time as a String */ public static String formatPeriod(long startMillis, long endMillis, String format) { return formatPeriod(startMillis, endMillis, format, true, TimeZone.getDefault()); }
public String replaceFPlayerTags(String s, FPlayer player) { if (s.contains("{balance}")) { String balance = Econ.isSetup() ? Econ.getFriendlyBalance(player) : "no balance"; s = s.replace("{balance}", balance); } if (s.contains("{lastSeen}")) { String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - player.getLastLoginTime(), true, true) + " ago"; String lastSeen = player.isOnline() ? ChatColor.GREEN + "Online" : (System.currentTimeMillis() - player.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized); s = s.replace("{lastSeen}", lastSeen); } if (s.contains("{power}")) { String power = player.getPowerRounded() + "/" + player.getPowerMaxRounded(); s = s.replace("{power}", power); } if (s.contains("{group}")) { String group = SavageFactions.plugin.getPrimaryGroup(Bukkit.getOfflinePlayer(UUID.fromString(player.getId()))); s = s.replace("{group}", group); } return s; }
public String toString() { return DurationFormatUtils.formatDurationHMS(getTime()); }
/** * <p>Formats the time gap as a string, using the specified format, and padding with zeros and * using the default timezone.</p> * * <p>This method formats durations using the days and lower fields of the * format pattern. Months and larger are not used.</p> * * @param durationMillis the duration to format * @param format the way in which to format the duration * @return the time as a String */ public static String formatDuration(long durationMillis, String format) { return formatDuration(durationMillis, format, true); }
/** * <p>Formats the time gap as a string.</p> * * <p>The format used is the ISO8601 period format.</p> * * @param startMillis the start of the duration to format * @param endMillis the end of the duration to format * @return the time as a String */ public static String formatPeriodISO(long startMillis, long endMillis) { return formatPeriod(startMillis, endMillis, ISO_EXTENDED_FORMAT_PATTERN, false, TimeZone.getDefault()); }
@Override public void perform() { ArrayList<String> ret = new ArrayList<>(); for (FPlayer fp : myFaction.getFPlayers()) { String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - fp.getLastLoginTime(), true, true) + TL.COMMAND_STATUS_AGOSUFFIX; String last = fp.isOnline() ? ChatColor.GREEN + TL.COMMAND_STATUS_ONLINE.toString() : (System.currentTimeMillis() - fp.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized); String power = ChatColor.YELLOW + String.valueOf(fp.getPowerRounded()) + " / " + fp.getPowerMaxRounded() + ChatColor.RESET; ret.add(String.format(TL.COMMAND_STATUS_FORMAT.toString(), ChatColor.GOLD + fp.getRole().getPrefix() + fp.getName() + ChatColor.RESET, power, last).trim()); } fme.sendMessage(ret); }
public String toSplitString() { return DurationFormatUtils.formatDurationHMS(getSplitTime()); }
String duration = formatDuration(durationMillis, "d' days 'H' hours 'm' minutes 's' seconds'"); if (suppressLeadingZeroElements) {