本文整理汇总了Java中java.time.Duration.plus方法的典型用法代码示例。如果您正苦于以下问题:Java Duration.plus方法的具体用法?Java Duration.plus怎么用?Java Duration.plus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.Duration
的用法示例。
在下文中一共展示了Duration.plus方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: plus_longTemporalUnit_seconds
import java.time.Duration; //导入方法依赖的package包/类
@Test
public void plus_longTemporalUnit_seconds() {
Duration t = Duration.ofSeconds(1);
t = t.plus(1, SECONDS);
assertEquals(2, t.getSeconds());
assertEquals(0, t.getNano());
}
示例2: plus_longTemporalUnit_millis
import java.time.Duration; //导入方法依赖的package包/类
@Test
public void plus_longTemporalUnit_millis() {
Duration t = Duration.ofSeconds(1);
t = t.plus(1, MILLIS);
assertEquals(1, t.getSeconds());
assertEquals(1000000, t.getNano());
}
示例3: plus_longTemporalUnit_micros
import java.time.Duration; //导入方法依赖的package包/类
@Test
public void plus_longTemporalUnit_micros() {
Duration t = Duration.ofSeconds(1);
t = t.plus(1, MICROS);
assertEquals(1, t.getSeconds());
assertEquals(1000, t.getNano());
}
示例4: plus_longTemporalUnit_nanos
import java.time.Duration; //导入方法依赖的package包/类
@Test
public void plus_longTemporalUnit_nanos() {
Duration t = Duration.ofSeconds(1);
t = t.plus(1, NANOS);
assertEquals(1, t.getSeconds());
assertEquals(1, t.getNano());
}
示例5: plusOverflowTooBig
import java.time.Duration; //导入方法依赖的package包/类
@Test(expectedExceptions=ArithmeticException.class)
public void plusOverflowTooBig() {
Duration t = Duration.ofSeconds(Long.MAX_VALUE, 999999999);
t.plus(Duration.ofSeconds(0, 1));
}
示例6: plusOverflowTooSmall
import java.time.Duration; //导入方法依赖的package包/类
@Test(expectedExceptions=ArithmeticException.class)
public void plusOverflowTooSmall() {
Duration t = Duration.ofSeconds(Long.MIN_VALUE);
t.plus(Duration.ofSeconds(-1, 999999999));
}
示例7: plus_longTemporalUnit_null
import java.time.Duration; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void plus_longTemporalUnit_null() {
Duration t = Duration.ofSeconds(1);
t.plus(1, (TemporalUnit) null);
}