本文整理汇总了Java中java.time.LocalTime.plusSeconds方法的典型用法代码示例。如果您正苦于以下问题:Java LocalTime.plusSeconds方法的具体用法?Java LocalTime.plusSeconds怎么用?Java LocalTime.plusSeconds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.LocalTime
的用法示例。
在下文中一共展示了LocalTime.plusSeconds方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_plusSeconds_one
import java.time.LocalTime; //导入方法依赖的package包/类
@Test
public void test_plusSeconds_one() {
LocalTime t = LocalTime.MIDNIGHT;
int hour = 0;
int min = 0;
int sec = 0;
for (int i = 0; i < 3700; i++) {
t = t.plusSeconds(1);
sec++;
if (sec == 60) {
min++;
sec = 0;
}
if (min == 60) {
hour++;
min = 0;
}
assertEquals(t.getHour(), hour);
assertEquals(t.getMinute(), min);
assertEquals(t.getSecond(), sec);
}
}
示例2: test_plusSeconds_fromZero
import java.time.LocalTime; //导入方法依赖的package包/类
@Test(dataProvider="plusSeconds_fromZero")
public void test_plusSeconds_fromZero(int seconds, int hour, int min, int sec) {
LocalTime base = LocalTime.MIDNIGHT;
LocalTime t = base.plusSeconds(seconds);
assertEquals(hour, t.getHour());
assertEquals(min, t.getMinute());
assertEquals(sec, t.getSecond());
}
示例3: test_toSecondOfDay
import java.time.LocalTime; //导入方法依赖的package包/类
@Test
public void test_toSecondOfDay() {
LocalTime t = LocalTime.of(0, 0);
for (int i = 0; i < 24 * 60 * 60; i++) {
assertEquals(t.toSecondOfDay(), i);
t = t.plusSeconds(1);
}
}
示例4: test_toSecondOfDay_fromNanoOfDay_symmetry
import java.time.LocalTime; //导入方法依赖的package包/类
@Test
public void test_toSecondOfDay_fromNanoOfDay_symmetry() {
LocalTime t = LocalTime.of(0, 0);
for (int i = 0; i < 24 * 60 * 60; i++) {
assertEquals(LocalTime.ofSecondOfDay(t.toSecondOfDay()), t);
t = t.plusSeconds(1);
}
}