本文整理匯總了Java中java.time.OffsetTime.ofInstant方法的典型用法代碼示例。如果您正苦於以下問題:Java OffsetTime.ofInstant方法的具體用法?Java OffsetTime.ofInstant怎麽用?Java OffsetTime.ofInstant使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.time.OffsetTime
的用法示例。
在下文中一共展示了OffsetTime.ofInstant方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: factory_ofInstant_allSecsInDay
import java.time.OffsetTime; //導入方法依賴的package包/類
@Test
public void factory_ofInstant_allSecsInDay() {
for (int i = 0; i < (2 * 24 * 60 * 60); i++) {
Instant instant = Instant.ofEpochSecond(i, 8);
OffsetTime test = OffsetTime.ofInstant(instant, ZoneOffset.UTC);
assertEquals(test.getHour(), (i / (60 * 60)) % 24);
assertEquals(test.getMinute(), (i / 60) % 60);
assertEquals(test.getSecond(), i % 60);
assertEquals(test.getNano(), 8);
}
}
示例2: factory_ofInstant_beforeEpoch
import java.time.OffsetTime; //導入方法依賴的package包/類
@Test
public void factory_ofInstant_beforeEpoch() {
for (int i =-1; i >= -(24 * 60 * 60); i--) {
Instant instant = Instant.ofEpochSecond(i, 8);
OffsetTime test = OffsetTime.ofInstant(instant, ZoneOffset.UTC);
assertEquals(test.getHour(), ((i + 24 * 60 * 60) / (60 * 60)) % 24);
assertEquals(test.getMinute(), ((i + 24 * 60 * 60) / 60) % 60);
assertEquals(test.getSecond(), (i + 24 * 60 * 60) % 60);
assertEquals(test.getNano(), 8);
}
}
示例3: factory_ofInstant_minYear
import java.time.OffsetTime; //導入方法依賴的package包/類
@Test
public void factory_ofInstant_minYear() {
OffsetTime test = OffsetTime.ofInstant(Instant.MIN, ZoneOffset.UTC);
assertEquals(test.getHour(), 0);
assertEquals(test.getMinute(), 0);
assertEquals(test.getSecond(), 0);
assertEquals(test.getNano(), 0);
}
示例4: factory_ofInstant_nullInstant
import java.time.OffsetTime; //導入方法依賴的package包/類
@Test(expectedExceptions=NullPointerException.class)
public void factory_ofInstant_nullInstant() {
OffsetTime.ofInstant((Instant) null, ZoneOffset.UTC);
}
示例5: factory_ofInstant_nullOffset
import java.time.OffsetTime; //導入方法依賴的package包/類
@Test(expectedExceptions=NullPointerException.class)
public void factory_ofInstant_nullOffset() {
Instant instant = Instant.ofEpochSecond(0L);
OffsetTime.ofInstant(instant, (ZoneOffset) null);
}