本文整理汇总了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);
}