当前位置: 首页>>代码示例>>Java>>正文


Java OffsetDateTime.toInstant方法代码示例

本文整理汇总了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));
}
 
开发者ID:rbi,项目名称:trading4j,代码行数:11,代码来源:M30.java

示例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));
}
 
开发者ID:rbi,项目名称:trading4j,代码行数:11,代码来源:M5.java

示例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));
}
 
开发者ID:rbi,项目名称:trading4j,代码行数:8,代码来源:M1.java

示例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));
}
 
开发者ID:rbi,项目名称:trading4j,代码行数:11,代码来源:M15.java

示例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));
}
 
开发者ID:rbi,项目名称:trading4j,代码行数:10,代码来源:H1.java

示例6: convert

import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Override
public Instant convert(OffsetDateTime source) {
	return source.toInstant();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:DateTimeConverters.java

示例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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:7,代码来源:TestOffsetDateTime_instants.java

示例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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:7,代码来源:TestOffsetDateTime_instants.java

示例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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:7,代码来源:TestOffsetDateTime_instants.java

示例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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:7,代码来源:TestOffsetDateTime_instants.java

示例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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:7,代码来源:TestOffsetDateTime_instants.java


注:本文中的java.time.OffsetDateTime.toInstant方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。