Java Code Examples for org.apache.commons.lang.time.DurationFormatUtils#formatDuration()
The following examples show how to use
org.apache.commons.lang.time.DurationFormatUtils#formatDuration() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TibcoUtils.java From iaf with Apache License 2.0 | 6 votes |
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 "?"; } }
Example 2
Source File: Misc.java From iaf with Apache License 2.0 | 6 votes |
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; }
Example 3
Source File: CountDownTimer.java From PocketEOS-Android with GNU Lesser General Public License v3.0 | 5 votes |
@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); } }
Example 4
Source File: SeverityResponseTimeHistoricMetricProvider.java From scava with Eclipse Public License 2.0 | 5 votes |
private String format(long avgDuration) { String formatted = null; if (avgDuration>0) { int days = (int) (avgDuration / SECONDS_DAY); long lessThanDay = (avgDuration % SECONDS_DAY); formatted = days + ":" + DurationFormatUtils.formatDuration(lessThanDay*1000, "HH:mm:ss:SS"); } else { formatted = 0 + ":" + DurationFormatUtils.formatDuration(0, "HH:mm:ss:SS"); } return formatted; }
Example 5
Source File: ResponseTimeHistoricMetricProvider.java From scava with Eclipse Public License 2.0 | 5 votes |
private String format(long avgDuration) { String formatted = null; if (avgDuration>0) { int days = (int) (avgDuration / SECONDS_DAY); long lessThanDay = (avgDuration % SECONDS_DAY); formatted = days + ":" + DurationFormatUtils.formatDuration(lessThanDay*1000, "HH:mm:ss:SS"); } else { formatted = 0 + ":" + DurationFormatUtils.formatDuration(0, "HH:mm:ss:SS"); } return formatted; }
Example 6
Source File: ResponseTimeHistoricMetricProvider.java From scava with Eclipse Public License 2.0 | 5 votes |
private String format(long avgDuration) { String formatted = null; if (avgDuration>0) { int days = (int) (avgDuration / SECONDS_DAY); long lessThanDay = (avgDuration % SECONDS_DAY); formatted = days + ":" + DurationFormatUtils.formatDuration(lessThanDay*1000, "HH:mm:ss:SS"); } else { formatted = 0 + ":" + DurationFormatUtils.formatDuration(0, "HH:mm:ss:SS"); } return formatted; }
Example 7
Source File: SeverityResponseTimeHistoricMetricProvider.java From scava with Eclipse Public License 2.0 | 5 votes |
private String format(long avgDuration) { String formatted = null; if (avgDuration>0) { int days = (int) (avgDuration / SECONDS_DAY); long lessThanDay = (avgDuration % SECONDS_DAY); formatted = days + ":" + DurationFormatUtils.formatDuration(lessThanDay*1000, "HH:mm:ss:SS"); } else { formatted = 0 + ":" + DurationFormatUtils.formatDuration(0, "HH:mm:ss:SS"); } return formatted; }
Example 8
Source File: MikyouCountDownTimer.java From LLApp with Apache License 2.0 | 5 votes |
@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); } }
Example 9
Source File: UberFormatter.java From antsdb with GNU Lesser General Public License v3.0 | 5 votes |
public static String duration(Duration d) { String result = null; if (d != null) { long ms = d.toMillis(); if (ms >= 0) { result = DurationFormatUtils.formatDuration(ms, "HH:mm:ss"); } else { result = DurationFormatUtils.formatDuration(-ms, "-HH:mm:ss"); } } return result; }
Example 10
Source File: Clock.java From statecharts with Eclipse Public License 1.0 | 5 votes |
protected void updateTimestamp(long timestamp) { if (timestamp == currentTime) return; currentTime = timestamp; String formatDurationHMS = DurationFormatUtils.formatDuration(timestamp, (timestamp == 0 ? "--:--:--.---" : "HH:mm:ss.SSS"), true); timeLabel.setText(formatDurationHMS); getParent().layout(); }
Example 11
Source File: Clock.java From statecharts with Eclipse Public License 1.0 | 5 votes |
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); }
Example 12
Source File: DateUtils.java From repairnator with MIT License | 4 votes |
public static String getDuration(Date dateBegin, Date dateEnd) { return DurationFormatUtils.formatDuration(dateEnd.getTime()-dateBegin.getTime(), "HH:mm", true); }
Example 13
Source File: GenericSkewHeuristic.java From dr-elephant with Apache License 2.0 | 4 votes |
private String convertTimeMs(long timeMs) { if (timeMs < 1000) { return Long.toString(timeMs) + " msec"; } return DurationFormatUtils.formatDuration(timeMs, "HH:mm:ss") + " HH:MM:SS"; }
Example 14
Source File: GenericDataSkewHeuristic.java From dr-elephant with Apache License 2.0 | 4 votes |
private String convertTimeMs(long timeMs) { if (timeMs < 1000) { return Long.toString(timeMs) + " msec"; } return DurationFormatUtils.formatDuration(timeMs, "HH:mm:ss") + " HH:MM:SS"; }
Example 15
Source File: AnnounceBar.java From AnnihilationPro with MIT License | 4 votes |
private static String format(long miliseconds) { return DurationFormatUtils.formatDuration(miliseconds, "mm:ss"); }
Example 16
Source File: Depict2.java From systemsgenetics with GNU General Public License v3.0 | 4 votes |
public static String formatMsForLog(long ms) { //return LOG_TIME_FORMAT.format(new Date(ms)); return DurationFormatUtils.formatDuration(ms, "H:mm:ss.S"); }