List of usage examples for org.apache.commons.lang3.time DurationFormatUtils formatDurationHMS
public static String formatDurationHMS(final long durationMillis)
Formats the time gap as a string.
The format used is ISO 8601-like: HH:mm:ss.SSS .
From source file:com.mgmtp.perfload.perfalyzer.util.TestMetadata.java
public static TestMetadata create(final String rawResultsDir, final Properties properties) { ZonedDateTime start = ZonedDateTime.parse(properties.getProperty("test.start"), DateTimeFormatter.ISO_OFFSET_DATE_TIME); ZonedDateTime end = ZonedDateTime.parse(properties.getProperty("test.finish"), DateTimeFormatter.ISO_OFFSET_DATE_TIME); String duration = DurationFormatUtils.formatDurationHMS(Duration.between(start, end).toMillis()); String operationsString = properties.getProperty("operations"); Set<String> operations = newTreeSet(on(',').trimResults().split(operationsString)); return new TestMetadata(start, end, duration, properties.getProperty("test.file"), rawResultsDir, properties.getProperty("perfload.implementation.version"), properties.getProperty("test.comment"), operations);/*from ww w . j a va 2 s . c o m*/ }
From source file:lineage2.gameserver.network.telnet.commands.TelnetServer.java
/** * Constructor for TelnetServer.//from ww w.ja v a 2s.c o m */ public TelnetServer() { _commands.add(new TelnetCommand("version", "ver") { @Override public String getUsage() { return "version"; } @Override public String handle(String[] args) { return "Rev." + GameServer.getInstance().getVersion().getRevisionNumber() + " Builded : " + GameServer.getInstance().getVersion().getBuildDate() + "\n"; } }); _commands.add(new TelnetCommand("uptime") { @Override public String getUsage() { return "uptime"; } @Override public String handle(String[] args) { return DurationFormatUtils.formatDurationHMS(ManagementFactory.getRuntimeMXBean().getUptime()) + "\n"; } }); _commands.add(new TelnetCommand("restart") { @Override public String getUsage() { return "restart <seconds>|now>"; } @Override public String handle(String[] args) { if (args.length == 0) { return null; } StringBuilder sb = new StringBuilder(); if (NumberUtils.isNumber(args[0])) { int val = NumberUtils.toInt(args[0]); Shutdown.getInstance().schedule(val, Shutdown.RESTART); sb.append("Server will restart in ").append(Shutdown.getInstance().getSeconds()) .append(" seconds!\n"); sb.append("Type \"abort\" to abort restart!\n"); } else if (args[0].equalsIgnoreCase("now")) { sb.append("Server will restart now!\n"); Shutdown.getInstance().schedule(0, Shutdown.RESTART); } else { String[] hhmm = args[0].split(":"); Calendar date = Calendar.getInstance(); Calendar now = Calendar.getInstance(); date.set(Calendar.HOUR_OF_DAY, Integer.parseInt(hhmm[0])); date.set(Calendar.MINUTE, hhmm.length > 1 ? Integer.parseInt(hhmm[1]) : 0); date.set(Calendar.SECOND, 0); date.set(Calendar.MILLISECOND, 0); if (date.before(now)) { date.roll(Calendar.DAY_OF_MONTH, true); } int seconds = (int) ((date.getTimeInMillis() / 1000L) - (now.getTimeInMillis() / 1000L)); Shutdown.getInstance().schedule(seconds, Shutdown.RESTART); sb.append("Server will restart in ").append(Shutdown.getInstance().getSeconds()) .append(" seconds!\n"); sb.append("Type \"abort\" to abort restart!\n"); } return sb.toString(); } }); _commands.add(new TelnetCommand("shutdown") { @Override public String getUsage() { return "shutdown <seconds>|now|<hh:mm>"; } @Override public String handle(String[] args) { if (args.length == 0) { return null; } StringBuilder sb = new StringBuilder(); if (NumberUtils.isNumber(args[0])) { int val = NumberUtils.toInt(args[0]); Shutdown.getInstance().schedule(val, Shutdown.SHUTDOWN); sb.append("Server will shutdown in ").append(Shutdown.getInstance().getSeconds()) .append(" seconds!\n"); sb.append("Type \"abort\" to abort shutdown!\n"); } else if (args[0].equalsIgnoreCase("now")) { sb.append("Server will shutdown now!\n"); Shutdown.getInstance().schedule(0, Shutdown.SHUTDOWN); } else { String[] hhmm = args[0].split(":"); Calendar date = Calendar.getInstance(); Calendar now = Calendar.getInstance(); date.set(Calendar.HOUR_OF_DAY, Integer.parseInt(hhmm[0])); date.set(Calendar.MINUTE, hhmm.length > 1 ? Integer.parseInt(hhmm[1]) : 0); date.set(Calendar.SECOND, 0); date.set(Calendar.MILLISECOND, 0); if (date.before(now)) { date.roll(Calendar.DAY_OF_MONTH, true); } int seconds = (int) ((date.getTimeInMillis() / 1000L) - (now.getTimeInMillis() / 1000L)); Shutdown.getInstance().schedule(seconds, Shutdown.SHUTDOWN); sb.append("Server will shutdown in ").append(Shutdown.getInstance().getSeconds()) .append(" seconds!\n"); sb.append("Type \"abort\" to abort shutdown!\n"); } return sb.toString(); } }); _commands.add(new TelnetCommand("abort") { @Override public String getUsage() { return "abort"; } @Override public String handle(String[] args) { Shutdown.getInstance().cancel(); return "Aborted.\n"; } }); }
From source file:de.upb.timok.ProgressEstimator.java
public synchronized String getLastJobTimeString() { return DurationFormatUtils.formatDurationHMS(getLastJobTime()); }
From source file:com.neophob.sematrix.cli.PixConClientJmx.java
/** * //from ww w . j a va2s . c o m * @param mbsc * @throws Exception */ private static void printJmxStatus(MBeanServerConnection mbsc) throws Exception { ObjectName mbeanName = new ObjectName(PixelControllerStatus.JMX_BEAN_NAME); PixelControllerStatusMBean mbeanProxy = JMX.newMBeanProxy(mbsc, mbeanName, PixelControllerStatusMBean.class, true); // print general status information System.out.println("\nGeneric:"); System.out.printf("%-25s: %s\n", "server version", mbeanProxy.getVersion()); System.out.printf("%-25s: %3.3f (%s of configured fps: %2.0f)\n", "current fps", mbeanProxy.getCurrentFps(), PERCENT_FORMAT.format(mbeanProxy.getCurrentFps() / mbeanProxy.getConfiguredFps()), mbeanProxy.getConfiguredFps()); System.out.printf("%-25s: %d\n", "frame count", mbeanProxy.getFrameCount()); System.out.printf("%-25s: %s\n", "running since", DurationFormatUtils.formatDurationHMS(System.currentTimeMillis() - mbeanProxy.getStartTime())); // print average timing information System.out.println("\nThe following average times have been collected during the last " + DurationFormatUtils.formatDuration(mbeanProxy.getRecordedMilliSeconds(), "ss.SSS") + " seconds:"); for (TimeMeasureItemGlobal valueEnum : TimeMeasureItemGlobal.values()) { System.out.printf(" %-22s: %3.3fms\n", valueEnum.getReadableName(), mbeanProxy.getAverageTime(valueEnum)); } // print output specific timing information for (int output = 0; output < mbeanProxy.getNumberOfOutputs(); output++) { System.out.println("\nOuput-specific average times for output #" + (output + 1) + ": " + mbeanProxy.getOutputType(output).getReadableName()); for (TimeMeasureItemOutput outputValueEnum : TimeMeasureItemOutput.values()) { System.out.printf(" %-22s: %3.3fms\n", outputValueEnum.getReadableName(), mbeanProxy.getOutputAverageTime(output, outputValueEnum)); } } }
From source file:com.squid.kraken.v4.caching.redis.queryworkerserver.QueryWorkerJobStatus.java
/** * for hierarchyQueries/*from w w w . j av a 2 s . c o m*/ * @param ustatus * @param projectPK2 * @param key2 * @param id2 * @param sqlQuery * @param start time * @param elapsed tume */ public QueryWorkerJobStatus(Status status, ProjectPK projectPK, String jobID, String key, int ID, String SQL, long linesRead, long start, long elapse) { this.status = status; this.projectPK = projectPK; this.jobID = jobID; this.key = key; this.ID = ID; this.SQL = SQL; this.elapse = elapse; this.lineRead = linesRead; this.elapseTime = DurationFormatUtils.formatDurationHMS(elapse); }
From source file:de.upb.timok.ProgressEstimator.java
public synchronized String getRemainingTimeString() { return DurationFormatUtils.formatDurationHMS(getRemainingTime()); }
From source file:at.ac.tuwien.big.moea.experiment.executor.listener.terminate.RuntimeTerminateListener.java
@Override public void update(final ProgressEvent event) { if (isSeedStarted(event)) { watch = new StopWatch(); watch.start();/*from w w w. j a v a2 s . co m*/ } if (terminateRun(event, watch.getNanoTime() > terminationTime)) { watch.stop(); System.out.println("--> Run " + event.getCurrentSeed() + " of " + event.getTotalSeeds() + " has been terminated after " + watch + ", because the time limit of " + DurationFormatUtils.formatDurationHMS(terminationTime / MathUtil.MILLISECONS_TO_NS) + " has been reached.\n"); } }
From source file:de.upb.timok.ProgressEstimator.java
public synchronized String getAverageJobTimeString() { return DurationFormatUtils.formatDurationHMS(getAverageJobTime()); }
From source file:de.upb.timok.ProgressEstimator.java
public synchronized String getOverallTimeString() { return DurationFormatUtils.formatDurationHMS(getOverallTime()); }
From source file:com.squid.kraken.v4.caching.redis.queryworkerserver.QueryWorkerJobStatus.java
/** * status is executing/*from w ww.j a va 2 s . c om*/ * @param userID2 * @param projectPK2 * @param key2 * @param id2 * @param sqlQuery */ public QueryWorkerJobStatus(String userID, ProjectPK projectPK, String jobID, String key, int ID, String SQL, long start, long elapse) { this.status = Status.EXECUTING; this.userID = userID; this.projectPK = projectPK; this.jobID = jobID; this.key = key; this.ID = ID; this.SQL = SQL; this.elapse = elapse; this.elapseTime = DurationFormatUtils.formatDurationHMS(elapse); }