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

The following examples show how to use java.time.LocalDateTime#atOffset() . These examples are extracted from open source projects. 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 Project: PgBulkInsert   File: TimeStampUtils.java    License: 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
private static OffsetDateTime toOffsetDateTime(LocalDateTime value) {
    return value.atOffset(ZoneId.systemDefault().getRules().getOffset(value));
}
 
Example 3
@Test(expectedExceptions=NullPointerException.class)
public void test_atOffset_nullZoneOffset() {
    LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30);
    t.atOffset((ZoneOffset) null);
}
 
Example 4
@Test(expectedExceptions=NullPointerException.class)
public void test_atOffset_nullZoneOffset() {
    LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30);
    t.atOffset((ZoneOffset) null);
}
 
Example 5
@Test(expectedExceptions=NullPointerException.class)
public void test_atOffset_nullZoneOffset() {
    LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30);
    t.atOffset((ZoneOffset) null);
}
 
Example 6
private static OffsetDateTime toOffsetDateTime(LocalDateTime value) {
    return value.atOffset(ZoneId.systemDefault().getRules().getOffset(value));
}
 
Example 7
@Test(expectedExceptions=NullPointerException.class)
public void test_atOffset_nullZoneOffset() {
    LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30);
    t.atOffset((ZoneOffset) null);
}
 
Example 8
@Test(expectedExceptions=NullPointerException.class)
public void test_atOffset_nullZoneOffset() {
    LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30);
    t.atOffset((ZoneOffset) null);
}
 
Example 9
@Test(expectedExceptions=NullPointerException.class)
public void test_atOffset_nullZoneOffset() {
    LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30);
    t.atOffset((ZoneOffset) null);
}
 
Example 10
@Test(expectedExceptions=NullPointerException.class)
public void test_atOffset_nullZoneOffset() {
    LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30);
    t.atOffset((ZoneOffset) null);
}
 
Example 11
@Test(expectedExceptions=NullPointerException.class)
public void test_atOffset_nullZoneOffset() {
    LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30);
    t.atOffset((ZoneOffset) null);
}
 
Example 12
@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 Project: FlinkExperiments   File: DateUtilities.java    License: 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 14
@Test(expectedExceptions=NullPointerException.class)
public void test_atOffset_nullZoneOffset() {
    LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30);
    t.atOffset((ZoneOffset) null);
}
 
Example 15
@Test(expectedExceptions=NullPointerException.class)
public void test_atOffset_nullZoneOffset() {
    LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30);
    t.atOffset((ZoneOffset) null);
}
 
Example 16
public static Date from(LocalDateTime localDateTime, ZoneOffset zoneOffset) {
    OffsetDateTime zdt = localDateTime.atOffset(zoneOffset);

    return Date.from(zdt.toInstant());
}
 
Example 17
@Test(expectedExceptions=NullPointerException.class)
public void test_atOffset_nullZoneOffset() {
    LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30);
    t.atOffset((ZoneOffset) null);
}
 
Example 18
@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 Project: j2objc   File: TCKLocalDateTime.java    License: 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 20
private TimeFrame asTimeFrame(LocalDateTime localStartDateTime, int utcOffsetInHours, Double durationInSeconds) {

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

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