当前位置: 首页>>代码示例>>Java>>正文


Java DurationFormatUtils.formatDuration方法代码示例

本文整理汇总了Java中org.apache.commons.lang3.time.DurationFormatUtils.formatDuration方法的典型用法代码示例。如果您正苦于以下问题:Java DurationFormatUtils.formatDuration方法的具体用法?Java DurationFormatUtils.formatDuration怎么用?Java DurationFormatUtils.formatDuration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang3.time.DurationFormatUtils的用法示例。


在下文中一共展示了DurationFormatUtils.formatDuration方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: displayStatistics

import org.apache.commons.lang3.time.DurationFormatUtils; //导入方法依赖的package包/类
protected void displayStatistics(long duration, int fileCount, long filesContentLength, long totalBytesHashed) {
    String totalFileContentLengthStr = byteCountToDisplaySize(filesContentLength);
    String totalBytesHashedStr = byteCountToDisplaySize(totalBytesHashed);
    String durationStr = DurationFormatUtils.formatDuration(duration, "HH:mm:ss");

    long durationSeconds = duration / 1000;
    if (durationSeconds <= 0) {
        durationSeconds = 1;
    }

    long globalThroughput = totalBytesHashed / durationSeconds;
    String throughputStr = byteCountToDisplaySize(globalThroughput);

    String usingThreads = "";
    if (context.isDynamicScaling()) {
        usingThreads = String.format(", using %d %s", context.getThreadCount(), plural("thread", context.getThreadCount()));
    }

    if (context.getHashMode() == dontHash) {
        Logger.info(String.format("Scanned %d %s (%s)%s, during %s%n",
            fileCount, plural("file", fileCount), totalFileContentLengthStr, usingThreads, durationStr));
    } else {
        Logger.info(String.format("Scanned %d %s (%s)%s, hashed %s (avg %s/s), during %s%n",
            fileCount, plural("file", fileCount), totalFileContentLengthStr, usingThreads, totalBytesHashedStr, throughputStr, durationStr));
    }
}
 
开发者ID:evrignaud,项目名称:fim,代码行数:27,代码来源:StateGenerator.java

示例2: execute

import org.apache.commons.lang3.time.DurationFormatUtils; //导入方法依赖的package包/类
@Override
public void execute(MessageReceivedEvent event, String[] args) {
    EmbedBuilder eb = new EmbedBuilder();
    eb.setColor(Color.getHSBColor(217,65,0));
    eb.setAuthor("LegendaryBot Stats","https://github.com/greatman/legendarybot","https://cdn.discordapp.com/app-icons/267134720700186626/ba3e3856b551e0c425280571db7746ef.jpg");

    RuntimeMXBean mxBean = ManagementFactory.getRuntimeMXBean();
    String uptime = DurationFormatUtils.formatDuration(mxBean.getUptime(), "d") + " days " + DurationFormatUtils.formatDuration(mxBean.getUptime()," HH:mm:ss");

    //Getting the runtime reference from system
    Runtime runtime = Runtime.getRuntime();
    int mb = 1024*1024;


    eb.addField(":homes:Guilds", plugin.getGuildCount() + "",true);
    eb.addField(":busts_in_silhouette: Members", plugin.getMemberCount() + "", true);
    eb.addField(":notepad_spiral:Text Channels", plugin.getTextChannelCount() + "", true);
    eb.addField(":loudspeaker:Voice Channels", plugin.getVoiceChannelCount() + "", true);
    eb.addField("Legendary checks", plugin.getLegendaryCount() + "", true);
    eb.addField(":timer:Uptime", uptime, true);

    eb.addField(":computer:Memory", "U: " +plugin.getUsedRam() + "MB / M: " + runtime.maxMemory() / mb + "MB", true);
    eb.addField(":speaker:Audio connections", plugin.getAudioConnections() + "", true);

    eb.addField(":musical_note: Song Queue", plugin.getSongQueue() + "", true);

    eb.setColor(Color.BLUE);

    event.getChannel().sendMessage(eb.build()).queue();


}
 
开发者ID:greatman,项目名称:legendarybot,代码行数:33,代码来源:BotStatsCommands.java

示例3: formatDuration

import org.apache.commons.lang3.time.DurationFormatUtils; //导入方法依赖的package包/类
public static String formatDuration(long millis) {
    String format = "mm:ss";
    if (millis > 3600000) {
        format = "HH:mm:ss";
    }
    return DurationFormatUtils.formatDuration(millis, format);
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:8,代码来源:CommonUtils.java

示例4: updateScoreboardTime

import org.apache.commons.lang3.time.DurationFormatUtils; //导入方法依赖的package包/类
protected void updateScoreboardTime() {
    if (scoreboard == null) {
        return;
    }
    Objective objective = scoreboard.getObjective("rounds");
    if (objective != null) {
        String s = DurationFormatUtils.formatDuration(ticksPassed * 50, "HH:mm:ss", true);
        objective.setDisplayName(ChatColor.GRAY.toString() + s + " | " + ChatColor.RED + "Score:");
    }
}
 
开发者ID:SpleefLeague,项目名称:SuperJump,代码行数:11,代码来源:AbstractBattle.java

示例5: formatDurationAsWords

import org.apache.commons.lang3.time.DurationFormatUtils; //导入方法依赖的package包/类
public static String formatDurationAsWords(long durationMillis, boolean showSeconds) {
    String format = "";
    String second = Res.get("time.second");
    String minute = Res.get("time.minute");
    String hour = Res.get("time.hour").toLowerCase();
    String day = Res.get("time.day").toLowerCase();
    String days = Res.get("time.days");
    String hours = Res.get("time.hours");
    String minutes = Res.get("time.minutes");
    String seconds = Res.get("time.seconds");

    if (durationMillis >= DateUtils.MILLIS_PER_DAY) {
        format = "d\' " + days + ", \'";
    }

    if (showSeconds) {
        format += "H\' " + hours + ", \'m\' " + minutes + ", \'s\' " + seconds + "\'";
    } else
        format += "H\' " + hours + ", \'m\' " + minutes + "\'";

    String duration = durationMillis > 0 ? DurationFormatUtils.formatDuration(durationMillis, format) : Res.get("formatter.tradePeriodOver");

    duration = StringUtils.replaceOnce(duration, "1 " + seconds, "1 " + second);
    duration = StringUtils.replaceOnce(duration, "1 " + minutes, "1 " + minute);
    duration = StringUtils.replaceOnce(duration, "1 " + hours, "1 " + hour);
    duration = StringUtils.replaceOnce(duration, "1 " + days, "1 " + day);
    return duration.trim();
}
 
开发者ID:bisq-network,项目名称:exchange,代码行数:29,代码来源:BSFormatter.java

示例6: formatDuration

import org.apache.commons.lang3.time.DurationFormatUtils; //导入方法依赖的package包/类
String formatDuration() {
    return DurationFormatUtils.formatDuration((long) (1000 * duration), "H:mm:ss.SSS");
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:4,代码来源:CreateKPITask.java

示例7: formatDuration

import org.apache.commons.lang3.time.DurationFormatUtils; //导入方法依赖的package包/类
private String formatDuration(long ms) {
    String fmt = ms >= TimeUnit.HOURS.toMillis(1) ? "H:mm:ss" : ms >= TimeUnit.MINUTES.toMillis(1) ? "m:ss" : "s's'";
    return DurationFormatUtils.formatDuration(ms, fmt);
}
 
开发者ID:tterrag1098,项目名称:MCBot,代码行数:5,代码来源:CommandQuote.java

示例8: formatShortDuration

import org.apache.commons.lang3.time.DurationFormatUtils; //导入方法依赖的package包/类
public static String formatShortDuration(long duration) {
	if(TimeUnit.MILLISECONDS.toHours(duration) > 0) {
		return DurationFormatUtils.formatDuration(duration, "H:mm:ss", true);
	}
	return DurationFormatUtils.formatDuration(duration, "m:ss", true);
}
 
开发者ID:Shadorc,项目名称:Shadbot,代码行数:7,代码来源:FormatUtils.java

示例9: formatDurationForMedia

import org.apache.commons.lang3.time.DurationFormatUtils; //导入方法依赖的package包/类
public static String formatDurationForMedia(final Duration currentTime) {
    return DurationFormatUtils.formatDuration((long) currentTime.toMillis(), "H:mm:ss", true);
}
 
开发者ID:Evegen55,项目名称:main_carauto_board,代码行数:4,代码来源:Util.java

示例10: getValue

import org.apache.commons.lang3.time.DurationFormatUtils; //导入方法依赖的package包/类
@Override
public Object getValue(final Long context) {
	return DurationFormatUtils.formatDuration(context, "HH:mm:ss");
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:5,代码来源:JiraExportPluginResource.java

示例11: duration

import org.apache.commons.lang3.time.DurationFormatUtils; //导入方法依赖的package包/类
public static String duration(final long start) {
  return DurationFormatUtils.formatDuration(System.currentTimeMillis() - start, DURATION_FORMAT);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:4,代码来源:JavaUtils.java

示例12: durationFromMillis

import org.apache.commons.lang3.time.DurationFormatUtils; //导入方法依赖的package包/类
public static String durationFromMillis(final long millis) {
  return DurationFormatUtils.formatDuration(millis, DURATION_FORMAT);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:4,代码来源:JavaUtils.java

示例13: start

import org.apache.commons.lang3.time.DurationFormatUtils; //导入方法依赖的package包/类
@Override
public void start() {
	final DLNAResource res = renderer.getPlayingRes();
	state.name = res.getDisplayName();
	duration = 0;
	if (res.getMedia() != null) {
		duration = (long) res.getMedia().getDurationInSeconds() * 1000;
		state.duration = DurationFormatUtils.formatDuration(duration, "HH:mm:ss");
	}
	Runnable r = new Runnable() {
		@Override
		public void run() {
			state.playback = PLAYING;
			while (res == renderer.getPlayingRes()) {
				long elapsed;
				if ((long) res.getLastStartPosition() == 0) {
					elapsed = System.currentTimeMillis() - res.getStartTime();
				} else {
					elapsed = System.currentTimeMillis() - (long) res.getLastStartSystemTime();
					elapsed += (long) (res.getLastStartPosition() * 1000);
				}

				if (duration == 0 || elapsed < duration + 500) {
					// Position is valid as far as we can tell
					state.position = DurationFormatUtils.formatDuration(elapsed, "HH:mm:ss");
				} else {
					// Position is invalid, blink instead
					state.position = ("NOT_IMPLEMENTED" + (elapsed / 1000 % 2 == 0 ? "  " : "--"));
				}
				alert();
				try {
					Thread.sleep(1000);
				} catch (InterruptedException e) {
				}
			}
			// Reset only if another item hasn't already begun playing
			if (renderer.getPlayingRes() == null) {
				reset();
			}
		}
	};
	new Thread(r).start();
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:44,代码来源:RendererConfiguration.java

示例14: formatDurationAsWords

import org.apache.commons.lang3.time.DurationFormatUtils; //导入方法依赖的package包/类
public static String formatDurationAsWords(long durationMillis, boolean showSeconds) {
    String format;
    String second = Res.get("time.second");
    String minute = Res.get("time.minute");
    String hour = Res.get("time.hour").toLowerCase();
    String day = Res.get("time.day").toLowerCase();
    String days = Res.get("time.days");
    String hours = Res.get("time.hours");
    String minutes = Res.get("time.minutes");
    String seconds = Res.get("time.seconds");
    if (showSeconds) {
        format = "d\' " + days + ", \'H\' " + hours + ", \'m\' " + minutes + ", \'s\' " + seconds + "\'";
    } else
        format = "d\' " + days + ", \'H\' " + hours + ", \'m\' " + minutes + "\'";
    String duration = DurationFormatUtils.formatDuration(durationMillis, format);
    String tmp;
    duration = " " + duration;
    tmp = StringUtils.replaceOnce(duration, " 0 " + days, "");
    if (tmp.length() != duration.length()) {
        duration = tmp;
        tmp = StringUtils.replaceOnce(tmp, " 0 " + hours, "");
        if (tmp.length() != duration.length()) {
            tmp = StringUtils.replaceOnce(tmp, " 0 " + minutes, "");
            duration = tmp;
            if (tmp.length() != tmp.length()) {
                duration = StringUtils.replaceOnce(tmp, " 0 " + seconds, "");
            }
        }
    }

    if (duration.length() != 0) {
        duration = duration.substring(1);
    }

    tmp = StringUtils.replaceOnce(duration, " 0 " + seconds, "");

    if (tmp.length() != duration.length()) {
        duration = tmp;
        tmp = StringUtils.replaceOnce(tmp, " 0 " + minutes, "");
        if (tmp.length() != duration.length()) {
            duration = tmp;
            tmp = StringUtils.replaceOnce(tmp, " 0 " + hours, "");
            if (tmp.length() != duration.length()) {
                duration = StringUtils.replaceOnce(tmp, " 0 " + days, "");
            }
        }
    }

    duration = " " + duration;
    duration = StringUtils.replaceOnce(duration, " 1 " + seconds, " 1 " + second);
    duration = StringUtils.replaceOnce(duration, " 1 " + minutes, " 1 " + minute);
    duration = StringUtils.replaceOnce(duration, " 1 " + hours, " 1 " + hour);
    duration = StringUtils.replaceOnce(duration, " 1 " + days, " 1 " + day);
    duration = duration.trim();
    if (duration.equals(","))
        duration = duration.replace(",", "");
    if (duration.startsWith(" ,"))
        duration = duration.replace(" ,", "");
    else if (duration.startsWith(", "))
        duration = duration.replace(", ", "");
    return duration;
}
 
开发者ID:bisq-network,项目名称:exchange,代码行数:63,代码来源:MetricsModel.java

示例15: uptimeToFormattedString

import org.apache.commons.lang3.time.DurationFormatUtils; //导入方法依赖的package包/类
private static String uptimeToFormattedString(long upTime) {
    return DurationFormatUtils.formatDuration(upTime, "HH:mm:ss");
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:4,代码来源:EmailSenderService.java


注:本文中的org.apache.commons.lang3.time.DurationFormatUtils.formatDuration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。