本文整理汇总了Java中java.time.OffsetDateTime.toInstant方法的典型用法代码示例。如果您正苦于以下问题:Java OffsetDateTime.toInstant方法的具体用法?Java OffsetDateTime.toInstant怎么用?Java OffsetDateTime.toInstant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.OffsetDateTime
的用法示例。
在下文中一共展示了OffsetDateTime.toInstant方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: areInSameTimeFrame
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Override
public boolean areInSameTimeFrame(final Instant instant1, final Instant instant2) {
final OffsetDateTime localBase = instant1.atOffset(UTC).withSecond(0).withNano(0);
final OffsetDateTime localStart = localBase.withMinute(localBase.getMinute() - localBase.getMinute() % 30);
final Instant start = localStart.toInstant();
final Instant startOfNext = localStart.plusMinutes(30).toInstant();
return instant2.equals(start) || (instant2.isAfter(start) && instant2.isBefore(startOfNext));
}
示例2: areInSameTimeFrame
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Override
public boolean areInSameTimeFrame(final Instant instant1, final Instant instant2) {
final OffsetDateTime localBase = instant1.atOffset(UTC).withSecond(0).withNano(0);
final OffsetDateTime localStart = localBase.withMinute(localBase.getMinute() - localBase.getMinute() % 5);
final Instant start = localStart.toInstant();
final Instant startOfNext = localStart.plusMinutes(5).toInstant();
return instant2.equals(start) || (instant2.isAfter(start) && instant2.isBefore(startOfNext));
}
示例3: areInSameTimeFrame
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Override
public boolean areInSameTimeFrame(final Instant instant1, final Instant instant2) {
final OffsetDateTime localStart = instant1.atOffset(UTC).withSecond(0).withNano(0);
final Instant start = localStart.toInstant();
final Instant startOfNext = localStart.plusMinutes(1).toInstant();
return instant2.equals(start) || (instant2.isAfter(start) && instant2.isBefore(startOfNext));
}
示例4: areInSameTimeFrame
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Override
public boolean areInSameTimeFrame(final Instant instant1, final Instant instant2) {
final OffsetDateTime localBase = instant1.atOffset(UTC).withSecond(0).withNano(0);
final OffsetDateTime localStart = localBase.withMinute(localBase.getMinute() - localBase.getMinute() % 15);
final Instant start = localStart.toInstant();
final Instant startOfNext = localStart.plusMinutes(15).toInstant();
return instant2.equals(start) || (instant2.isAfter(start) && instant2.isBefore(startOfNext));
}
示例5: areInSameTimeFrame
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Override
public boolean areInSameTimeFrame(final Instant instant1, final Instant instant2) {
final OffsetDateTime localStart = instant1.atOffset(UTC).withMinute(0).withSecond(0).withNano(0);
final Instant start = localStart.toInstant();
final Instant startOfNext = localStart.plusHours(1).toInstant();
return instant2.equals(start) || (instant2.isAfter(start) && instant2.isBefore(startOfNext));
}
示例6: convert
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Override
public Instant convert(OffsetDateTime source) {
return source.toInstant();
}
示例7: test_toInstant_19700101
import java.time.OffsetDateTime; //导入方法依赖的package包/类
public void test_toInstant_19700101() {
OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1970, 1, 1), LocalTime.of(0, 0, 0, 0), ZoneOffset.UTC);
Instant test = dt.toInstant();
assertEquals(test.getEpochSecond(), 0);
assertEquals(test.getNano(), 0);
}
示例8: test_toInstant_19700101_oneNano
import java.time.OffsetDateTime; //导入方法依赖的package包/类
public void test_toInstant_19700101_oneNano() {
OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1970, 1, 1), LocalTime.of(0, 0, 0, 1), ZoneOffset.UTC);
Instant test = dt.toInstant();
assertEquals(test.getEpochSecond(), 0);
assertEquals(test.getNano(), 1);
}
示例9: test_toInstant_19700101_minusOneNano
import java.time.OffsetDateTime; //导入方法依赖的package包/类
public void test_toInstant_19700101_minusOneNano() {
OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1969, 12, 31), LocalTime.of(23, 59, 59, 999999999), ZoneOffset.UTC);
Instant test = dt.toInstant();
assertEquals(test.getEpochSecond(), -1);
assertEquals(test.getNano(), 999999999);
}
示例10: test_toInstant_19700102
import java.time.OffsetDateTime; //导入方法依赖的package包/类
public void test_toInstant_19700102() {
OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1970, 1, 2), LocalTime.of(0, 0, 0, 0), ZoneOffset.UTC);
Instant test = dt.toInstant();
assertEquals(test.getEpochSecond(), 24L * 60L * 60L);
assertEquals(test.getNano(), 0);
}
示例11: test_toInstant_19691231
import java.time.OffsetDateTime; //导入方法依赖的package包/类
public void test_toInstant_19691231() {
OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1969, 12, 31), LocalTime.of(0, 0, 0, 0), ZoneOffset.UTC);
Instant test = dt.toInstant();
assertEquals(test.getEpochSecond(), -24L * 60L * 60L);
assertEquals(test.getNano(), 0);
}