本文整理了Java中org.fujion.common.DateUtil.parseElapsed()
方法的一些代码示例,展示了DateUtil.parseElapsed()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateUtil.parseElapsed()
方法的具体详情如下:
包路径:org.fujion.common.DateUtil
类名称:DateUtil
方法名:parseElapsed
[英]Parses an elapsed time string, returning time in milliseconds.
[中]解析已用时间字符串,以毫秒为单位返回时间。
代码示例来源:origin: org.fujion/fujion-common
/**
* Parses an elapsed time string, returning time in milliseconds.
*
* @param value The string value to parse.
* @return The elapsed time value in milliseconds.
*/
public static double parseElapsed(String value) {
return parseElapsed(value, TimeUnit.MILLISECONDS);
}
代码示例来源:origin: org.fujion/fujion-common
@Test
public void testElapsed() {
assertEquals("0.1 seconds", DateUtil.formatElapsed(100.0, TimeUnit.SECONDS));
assertEquals("1 second", DateUtil.formatElapsed(1000.0));
assertEquals("1 minute", DateUtil.formatElapsed(60000.0));
assertEquals("3.59 days", DateUtil.formatElapsed(309898934.0));
assertEquals("98.2 years", DateUtil.formatElapsed(3098989343984.0));
assertEquals("-98.2 years", DateUtil.formatElapsed(-3098989343984.0));
assertEquals(100.0, DateUtil.parseElapsed("0.1 seconds"), 0.0);
assertEquals(1000.0, DateUtil.parseElapsed("1 second"), 0.0);
assertEquals(60000.0, DateUtil.parseElapsed("1 minute"), 0.0);
assertEquals(310176000.0, DateUtil.parseElapsed("3.59 days"), 0.0);
assertEquals(3098956320000.0, DateUtil.parseElapsed("98.2 years"), 0.0);
assertEquals(-3098956320000.0, DateUtil.parseElapsed("-98.2 years"), 0.0);
assertEquals(98.2, DateUtil.parseElapsed("98.2 years", TimeUnit.YEARS), 0.0);
}
内容来源于网络,如有侵权,请联系作者删除!