Java Code Examples for java.time.LocalDateTime#atOffset()

The following examples show how to use java.time.LocalDateTime#atOffset() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TimeStampUtils.java    From PgBulkInsert with MIT License 5 votes vote down vote up
private static long getSecondsSinceJavaEpoch(LocalDateTime localDateTime) {
    // Adjust TimeZone Offset:
    OffsetDateTime zdt = localDateTime.atOffset(ZoneOffset.UTC);
    // Get the Epoch Milliseconds:
    long milliseconds = zdt.toInstant().toEpochMilli();
    // Turn into Seconds:
    return TimeUnit.MILLISECONDS.toSeconds(milliseconds);
}
 
Example 2
Source File: TCKLocalDateTime.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void test_atOffset_nullZoneOffset() {
    LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30);
    t.atOffset((ZoneOffset) null);
}
 
Example 3
Source File: TCKLocalDateTime.java    From j2objc with Apache License 2.0 4 votes vote down vote up
@Test(expected=NullPointerException.class)
public void test_atOffset_nullZoneOffset() {
    LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30);
    t.atOffset((ZoneOffset) null);
}
 
Example 4
Source File: TCKLocalDateTime.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void test_atOffset_nullZoneOffset() {
    LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30);
    t.atOffset((ZoneOffset) null);
}
 
Example 5
Source File: TCKLocalDateTime.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void test_atOffset_nullZoneOffset() {
    LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30);
    t.atOffset((ZoneOffset) null);
}
 
Example 6
Source File: DateUtilities.java    From JavaElasticSearchExperiment with MIT License 4 votes vote down vote up
public static Date from(LocalDateTime localDateTime, ZoneOffset zoneOffset) {
    OffsetDateTime zdt = localDateTime.atOffset(zoneOffset);

    return Date.from(zdt.toInstant());
}
 
Example 7
Source File: TCKLocalDateTime.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void test_atOffset_nullZoneOffset() {
    LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30);
    t.atOffset((ZoneOffset) null);
}
 
Example 8
Source File: TCKLocalDateTime.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void test_atOffset_nullZoneOffset() {
    LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30);
    t.atOffset((ZoneOffset) null);
}
 
Example 9
Source File: DateUtilities.java    From FlinkExperiments with MIT License 4 votes vote down vote up
public static Date from(LocalDateTime localDateTime, ZoneOffset zoneOffset) {
    OffsetDateTime offsetDateTime = localDateTime.atOffset(zoneOffset);

    return Date.from(offsetDateTime.toInstant());
}
 
Example 10
Source File: TCKLocalDateTime.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void test_atOffset_nullZoneOffset() {
    LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30);
    t.atOffset((ZoneOffset) null);
}
 
Example 11
Source File: TCKLocalDateTime.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void test_atOffset_nullZoneOffset() {
    LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30);
    t.atOffset((ZoneOffset) null);
}
 
Example 12
Source File: TCKLocalDateTime.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void test_atOffset_nullZoneOffset() {
    LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30);
    t.atOffset((ZoneOffset) null);
}
 
Example 13
Source File: TCKLocalDateTime.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void test_atOffset_nullZoneOffset() {
    LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30);
    t.atOffset((ZoneOffset) null);
}
 
Example 14
Source File: TCKLocalDateTime.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void test_atOffset_nullZoneOffset() {
    LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30);
    t.atOffset((ZoneOffset) null);
}
 
Example 15
Source File: TCKLocalDateTime.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void test_atOffset_nullZoneOffset() {
    LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30);
    t.atOffset((ZoneOffset) null);
}
 
Example 16
Source File: TimeZoneIntegrationTestSupport.java    From r2dbc-mysql with Apache License 2.0 4 votes vote down vote up
private static OffsetDateTime toOffsetDateTime(LocalDateTime value) {
    return value.atOffset(ZoneId.systemDefault().getRules().getOffset(value));
}
 
Example 17
Source File: TCKLocalDateTime.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void test_atOffset_nullZoneOffset() {
    LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30);
    t.atOffset((ZoneOffset) null);
}
 
Example 18
Source File: TCKLocalDateTime.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void test_atOffset_nullZoneOffset() {
    LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30);
    t.atOffset((ZoneOffset) null);
}
 
Example 19
Source File: TimeZoneIntegrationTestSupport.java    From r2dbc-mysql with Apache License 2.0 4 votes vote down vote up
private static OffsetDateTime toOffsetDateTime(LocalDateTime value) {
    return value.atOffset(ZoneId.systemDefault().getRules().getOffset(value));
}
 
Example 20
Source File: RunkeeperDataPointMapper.java    From shimmer with Apache License 2.0 2 votes vote down vote up
private TimeFrame asTimeFrame(LocalDateTime localStartDateTime, int utcOffsetInHours, Double durationInSeconds) {

        OffsetDateTime startDateTime = localStartDateTime.atOffset(ZoneOffset.ofHours(utcOffsetInHours));

        return new TimeFrame(ofStartDateTimeAndDuration(startDateTime, SECOND.newUnitValue(durationInSeconds)));
    }