本文整理了Java中org.fujion.common.DateUtil.formatDuration()
方法的一些代码示例,展示了DateUtil.formatDuration()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateUtil.formatDuration()
方法的具体详情如下:
包路径:org.fujion.common.DateUtil
类名称:DateUtil
方法名:formatDuration
[英]Formats a duration in ms.
[中]以毫秒为单位格式化持续时间。
代码示例来源:origin: org.fujion/fujion-common
/**
* Formats a duration in ms.
*
* @param duration Duration in ms.
* @return Formatted duration.
*/
public static String formatDuration(long duration) {
return formatDuration(duration, null);
}
代码示例来源:origin: org.fujion/fujion-common
/**
* Formats a duration in ms to the specified accuracy.
*
* @param duration Duration in ms.
* @param accuracy Accuracy of output.
* @return Formatted duration.
*/
public static String formatDuration(long duration, TimeUnit accuracy) {
return formatDuration(duration, accuracy, true, false);
}
代码示例来源:origin: org.fujion/fujion-common
@Test
public void testDuration() {
assertEquals("0 seconds", DateUtil.formatDuration(100, TimeUnit.SECONDS));
assertEquals("0 sec", DateUtil.formatDuration(100, TimeUnit.SECONDS, false, true));
assertEquals("1 second", DateUtil.formatDuration(1000, TimeUnit.SECONDS));
assertEquals("1 minute", DateUtil.formatDuration(60000, TimeUnit.SECONDS));
assertEquals("3 days 14 hours 4 minutes 58 seconds", DateUtil.formatDuration(309898934, TimeUnit.SECONDS));
assertEquals("3 day 14 hour 4 minute 58 second", DateUtil.formatDuration(309898934, TimeUnit.SECONDS, false, false));
assertEquals("98 years 2 months 1 week 6 days 10 hours 22 minutes 23 seconds",
DateUtil.formatDuration(3098989343984L, TimeUnit.SECONDS));
assertEquals("3 days 14 hrs 4 mins 58 secs", DateUtil.formatDuration(309898934, TimeUnit.SECONDS, true, true));
assertEquals("-98 years 2 months 1 week 6 days 10 hours 22 minutes 23 seconds",
DateUtil.formatDuration(-3098989343984L, TimeUnit.SECONDS));
}
代码示例来源:origin: org.carewebframework/org.carewebframework.ui.core
private void updateCountdown() {
if (state == State.COUNTDOWN) {
String s = nextMode().getLabel(TIMEOUT_WARNING, DateUtil.formatDuration(countdown, TimeUnit.SECONDS));
lblDuration.setLabel(s);
timeoutPanel.addClass("alert:" + (countdown <= 10000 ? "alert-danger" : "alert-warning"));
}
}
内容来源于网络,如有侵权,请联系作者删除!