本文整理匯總了Java中java.time.Instant.plusMillis方法的典型用法代碼示例。如果您正苦於以下問題:Java Instant.plusMillis方法的具體用法?Java Instant.plusMillis怎麽用?Java Instant.plusMillis使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.time.Instant
的用法示例。
在下文中一共展示了Instant.plusMillis方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: generateValue
import java.time.Instant; //導入方法依賴的package包/類
@Override
public Instant generateValue() {
switch (generator) {
case CONSTANT: return start;
case INCREMENT:
Instant current = currentInc;
currentInc = current.plusMillis(step.toEpochMilli());
return current;
case RANDOM: return generateRandom();
default:
return null;
}
}
示例2: plusMillis_long
import java.time.Instant; //導入方法依賴的package包/類
@Test(dataProvider="PlusMillis")
public void plusMillis_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
Instant t = Instant.ofEpochSecond(seconds, nanos);
t = t.plusMillis(amount);
assertEquals(t.getEpochSecond(), expectedSeconds);
assertEquals(t.getNano(), expectedNanoOfSecond);
}
示例3: plusMillis_long_oneMore
import java.time.Instant; //導入方法依賴的package包/類
@Test(dataProvider="PlusMillis")
public void plusMillis_long_oneMore(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
Instant t = Instant.ofEpochSecond(seconds + 1, nanos);
t = t.plusMillis(amount);
assertEquals(t.getEpochSecond(), expectedSeconds + 1);
assertEquals(t.getNano(), expectedNanoOfSecond);
}
示例4: plusMillis_long_minusOneLess
import java.time.Instant; //導入方法依賴的package包/類
@Test(dataProvider="PlusMillis")
public void plusMillis_long_minusOneLess(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
Instant t = Instant.ofEpochSecond(seconds - 1, nanos);
t = t.plusMillis(amount);
assertEquals(t.getEpochSecond(), expectedSeconds - 1);
assertEquals(t.getNano(), expectedNanoOfSecond);
}
示例5: plusMillis_long_max
import java.time.Instant; //導入方法依賴的package包/類
@Test
public void plusMillis_long_max() {
Instant t = Instant.ofEpochSecond(MAX_SECOND, 998999999);
t = t.plusMillis(1);
assertEquals(t.getEpochSecond(), MAX_SECOND);
assertEquals(t.getNano(), 999999999);
}
示例6: plusMillis_long_min
import java.time.Instant; //導入方法依賴的package包/類
@Test
public void plusMillis_long_min() {
Instant t = Instant.ofEpochSecond(MIN_SECOND, 1000000);
t = t.plusMillis(-1);
assertEquals(t.getEpochSecond(), MIN_SECOND);
assertEquals(t.getNano(), 0);
}
示例7: plusMillis_long_overflowTooBig
import java.time.Instant; //導入方法依賴的package包/類
@Test(expectedExceptions=DateTimeException.class)
public void plusMillis_long_overflowTooBig() {
Instant t = Instant.ofEpochSecond(MAX_SECOND, 999000000);
t.plusMillis(1);
}
示例8: plusMillis_long_overflowTooSmall
import java.time.Instant; //導入方法依賴的package包/類
@Test(expectedExceptions=DateTimeException.class)
public void plusMillis_long_overflowTooSmall() {
Instant t = Instant.ofEpochSecond(MIN_SECOND, 0);
t.plusMillis(-1);
}