Java Code Examples for java.time.ZonedDateTime#toOffsetDateTime()

The following examples show how to use java.time.ZonedDateTime#toOffsetDateTime() . 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: TCKZoneOffset.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_adjustInto_ZonedDateTime() {
    ZoneOffset base = ZoneOffset.ofHoursMinutesSeconds(1, 1, 1);
    for (String zoneId : ZoneId.getAvailableZoneIds()) {
        //Do not change offset of ZonedDateTime after adjustInto()
        ZonedDateTime zonedDateTime_target = ZonedDateTime.of(LocalDate.of(1909, 2, 2), LocalTime.of(10, 10, 10), ZoneId.of(zoneId));
        ZonedDateTime zonedDateTime_result = (ZonedDateTime)(base.adjustInto(zonedDateTime_target));
        assertEquals(zonedDateTime_target.getOffset(), zonedDateTime_result.getOffset());

        OffsetDateTime offsetDateTime_target = zonedDateTime_target.toOffsetDateTime();
        OffsetDateTime offsetDateTime_result = (OffsetDateTime)(base.adjustInto(offsetDateTime_target));
        assertEquals(base, offsetDateTime_result.getOffset());
    }
}
 
Example 2
Source File: TimestampColumnOffsetTimeMapper.java    From jadira with Apache License 2.0 5 votes vote down vote up
@Override
public OffsetTime fromNonNullValue(Timestamp value) {

	ZoneId currentJavaZone = javaZone == null ? getDefaultZoneId() : javaZone;

    ZonedDateTime zonedDateTime = value.toInstant().with(ChronoField.NANO_OF_SECOND, value.getNanos()).atZone(currentJavaZone);
    OffsetDateTime dateTime = zonedDateTime.toOffsetDateTime();
    
    OffsetTime time = dateTime.toOffsetTime();   
    return time;
}
 
Example 3
Source File: TCKZoneOffset.java    From j2objc with Apache License 2.0 5 votes vote down vote up
@Test
public void test_adjustInto_ZonedDateTime() {
    ZoneOffset base = ZoneOffset.ofHoursMinutesSeconds(1, 1, 1);
    for (String zoneId : ZoneId.getAvailableZoneIds()) {
        //Do not change offset of ZonedDateTime after adjustInto()
        ZonedDateTime zonedDateTime_target = ZonedDateTime.of(LocalDate.of(1909, 2, 2), LocalTime.of(10, 10, 10), ZoneId.of(zoneId));
        ZonedDateTime zonedDateTime_result = (ZonedDateTime)(base.adjustInto(zonedDateTime_target));
        assertEquals(zonedDateTime_target.getOffset(), zonedDateTime_result.getOffset());

        OffsetDateTime offsetDateTime_target = zonedDateTime_target.toOffsetDateTime();
        OffsetDateTime offsetDateTime_result = (OffsetDateTime)(base.adjustInto(offsetDateTime_target));
        assertEquals(base, offsetDateTime_result.getOffset());
    }
}
 
Example 4
Source File: TCKZoneOffset.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_adjustInto_ZonedDateTime() {
    ZoneOffset base = ZoneOffset.ofHoursMinutesSeconds(1, 1, 1);
    for (String zoneId : ZoneId.getAvailableZoneIds()) {
        //Do not change offset of ZonedDateTime after adjustInto()
        ZonedDateTime zonedDateTime_target = ZonedDateTime.of(LocalDate.of(1909, 2, 2), LocalTime.of(10, 10, 10), ZoneId.of(zoneId));
        ZonedDateTime zonedDateTime_result = (ZonedDateTime)(base.adjustInto(zonedDateTime_target));
        assertEquals(zonedDateTime_target.getOffset(), zonedDateTime_result.getOffset());

        OffsetDateTime offsetDateTime_target = zonedDateTime_target.toOffsetDateTime();
        OffsetDateTime offsetDateTime_result = (OffsetDateTime)(base.adjustInto(offsetDateTime_target));
        assertEquals(base, offsetDateTime_result.getOffset());
    }
}
 
Example 5
Source File: TCKZoneOffset.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_adjustInto_ZonedDateTime() {
    ZoneOffset base = ZoneOffset.ofHoursMinutesSeconds(1, 1, 1);
    for (String zoneId : ZoneId.getAvailableZoneIds()) {
        //Do not change offset of ZonedDateTime after adjustInto()
        ZonedDateTime zonedDateTime_target = ZonedDateTime.of(LocalDate.of(1909, 2, 2), LocalTime.of(10, 10, 10), ZoneId.of(zoneId));
        ZonedDateTime zonedDateTime_result = (ZonedDateTime)(base.adjustInto(zonedDateTime_target));
        assertEquals(zonedDateTime_target.getOffset(), zonedDateTime_result.getOffset());

        OffsetDateTime offsetDateTime_target = zonedDateTime_target.toOffsetDateTime();
        OffsetDateTime offsetDateTime_result = (OffsetDateTime)(base.adjustInto(offsetDateTime_target));
        assertEquals(base, offsetDateTime_result.getOffset());
    }
}
 
Example 6
Source File: TCKZoneOffset.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_adjustInto_ZonedDateTime() {
    ZoneOffset base = ZoneOffset.ofHoursMinutesSeconds(1, 1, 1);
    for (String zoneId : ZoneId.getAvailableZoneIds()) {
        //Do not change offset of ZonedDateTime after adjustInto()
        ZonedDateTime zonedDateTime_target = ZonedDateTime.of(LocalDate.of(1909, 2, 2), LocalTime.of(10, 10, 10), ZoneId.of(zoneId));
        ZonedDateTime zonedDateTime_result = (ZonedDateTime)(base.adjustInto(zonedDateTime_target));
        assertEquals(zonedDateTime_target.getOffset(), zonedDateTime_result.getOffset());

        OffsetDateTime offsetDateTime_target = zonedDateTime_target.toOffsetDateTime();
        OffsetDateTime offsetDateTime_result = (OffsetDateTime)(base.adjustInto(offsetDateTime_target));
        assertEquals(base, offsetDateTime_result.getOffset());
    }
}
 
Example 7
Source File: TCKZoneOffset.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_adjustInto_ZonedDateTime() {
    ZoneOffset base = ZoneOffset.ofHoursMinutesSeconds(1, 1, 1);
    for (String zoneId : ZoneId.getAvailableZoneIds()) {
        //Do not change offset of ZonedDateTime after adjustInto()
        ZonedDateTime zonedDateTime_target = ZonedDateTime.of(LocalDate.of(1909, 2, 2), LocalTime.of(10, 10, 10), ZoneId.of(zoneId));
        ZonedDateTime zonedDateTime_result = (ZonedDateTime)(base.adjustInto(zonedDateTime_target));
        assertEquals(zonedDateTime_target.getOffset(), zonedDateTime_result.getOffset());

        OffsetDateTime offsetDateTime_target = zonedDateTime_target.toOffsetDateTime();
        OffsetDateTime offsetDateTime_result = (OffsetDateTime)(base.adjustInto(offsetDateTime_target));
        assertEquals(base, offsetDateTime_result.getOffset());
    }
}
 
Example 8
Source File: TCKZoneOffset.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_adjustInto_ZonedDateTime() {
    ZoneOffset base = ZoneOffset.ofHoursMinutesSeconds(1, 1, 1);
    for (String zoneId : ZoneId.getAvailableZoneIds()) {
        //Do not change offset of ZonedDateTime after adjustInto()
        ZonedDateTime zonedDateTime_target = ZonedDateTime.of(LocalDate.of(1909, 2, 2), LocalTime.of(10, 10, 10), ZoneId.of(zoneId));
        ZonedDateTime zonedDateTime_result = (ZonedDateTime)(base.adjustInto(zonedDateTime_target));
        assertEquals(zonedDateTime_target.getOffset(), zonedDateTime_result.getOffset());

        OffsetDateTime offsetDateTime_target = zonedDateTime_target.toOffsetDateTime();
        OffsetDateTime offsetDateTime_result = (OffsetDateTime)(base.adjustInto(offsetDateTime_target));
        assertEquals(base, offsetDateTime_result.getOffset());
    }
}
 
Example 9
Source File: TCKZoneOffset.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_adjustInto_ZonedDateTime() {
    ZoneOffset base = ZoneOffset.ofHoursMinutesSeconds(1, 1, 1);
    for (String zoneId : ZoneId.getAvailableZoneIds()) {
        //Do not change offset of ZonedDateTime after adjustInto()
        ZonedDateTime zonedDateTime_target = ZonedDateTime.of(LocalDate.of(1909, 2, 2), LocalTime.of(10, 10, 10), ZoneId.of(zoneId));
        ZonedDateTime zonedDateTime_result = (ZonedDateTime)(base.adjustInto(zonedDateTime_target));
        assertEquals(zonedDateTime_target.getOffset(), zonedDateTime_result.getOffset());

        OffsetDateTime offsetDateTime_target = zonedDateTime_target.toOffsetDateTime();
        OffsetDateTime offsetDateTime_result = (OffsetDateTime)(base.adjustInto(offsetDateTime_target));
        assertEquals(base, offsetDateTime_result.getOffset());
    }
}
 
Example 10
Source File: TCKZoneOffset.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_adjustInto_ZonedDateTime() {
    ZoneOffset base = ZoneOffset.ofHoursMinutesSeconds(1, 1, 1);
    for (String zoneId : ZoneId.getAvailableZoneIds()) {
        //Do not change offset of ZonedDateTime after adjustInto()
        ZonedDateTime zonedDateTime_target = ZonedDateTime.of(LocalDate.of(1909, 2, 2), LocalTime.of(10, 10, 10), ZoneId.of(zoneId));
        ZonedDateTime zonedDateTime_result = (ZonedDateTime)(base.adjustInto(zonedDateTime_target));
        assertEquals(zonedDateTime_target.getOffset(), zonedDateTime_result.getOffset());

        OffsetDateTime offsetDateTime_target = zonedDateTime_target.toOffsetDateTime();
        OffsetDateTime offsetDateTime_result = (OffsetDateTime)(base.adjustInto(offsetDateTime_target));
        assertEquals(base, offsetDateTime_result.getOffset());
    }
}
 
Example 11
Source File: TCKZoneOffset.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_adjustInto_ZonedDateTime() {
    ZoneOffset base = ZoneOffset.ofHoursMinutesSeconds(1, 1, 1);
    for (String zoneId : ZoneId.getAvailableZoneIds()) {
        //Do not change offset of ZonedDateTime after adjustInto()
        ZonedDateTime zonedDateTime_target = ZonedDateTime.of(LocalDate.of(1909, 2, 2), LocalTime.of(10, 10, 10), ZoneId.of(zoneId));
        ZonedDateTime zonedDateTime_result = (ZonedDateTime)(base.adjustInto(zonedDateTime_target));
        assertEquals(zonedDateTime_target.getOffset(), zonedDateTime_result.getOffset());

        OffsetDateTime offsetDateTime_target = zonedDateTime_target.toOffsetDateTime();
        OffsetDateTime offsetDateTime_result = (OffsetDateTime)(base.adjustInto(offsetDateTime_target));
        assertEquals(base, offsetDateTime_result.getOffset());
    }
}
 
Example 12
Source File: TCKZoneOffset.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_adjustInto_ZonedDateTime() {
    ZoneOffset base = ZoneOffset.ofHoursMinutesSeconds(1, 1, 1);
    for (String zoneId : ZoneId.getAvailableZoneIds()) {
        //Do not change offset of ZonedDateTime after adjustInto()
        ZonedDateTime zonedDateTime_target = ZonedDateTime.of(LocalDate.of(1909, 2, 2), LocalTime.of(10, 10, 10), ZoneId.of(zoneId));
        ZonedDateTime zonedDateTime_result = (ZonedDateTime)(base.adjustInto(zonedDateTime_target));
        assertEquals(zonedDateTime_target.getOffset(), zonedDateTime_result.getOffset());

        OffsetDateTime offsetDateTime_target = zonedDateTime_target.toOffsetDateTime();
        OffsetDateTime offsetDateTime_result = (OffsetDateTime)(base.adjustInto(offsetDateTime_target));
        assertEquals(base, offsetDateTime_result.getOffset());
    }
}
 
Example 13
Source File: TCKZoneOffset.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_adjustInto_ZonedDateTime() {
    ZoneOffset base = ZoneOffset.ofHoursMinutesSeconds(1, 1, 1);
    for (String zoneId : ZoneId.getAvailableZoneIds()) {
        //Do not change offset of ZonedDateTime after adjustInto()
        ZonedDateTime zonedDateTime_target = ZonedDateTime.of(LocalDate.of(1909, 2, 2), LocalTime.of(10, 10, 10), ZoneId.of(zoneId));
        ZonedDateTime zonedDateTime_result = (ZonedDateTime)(base.adjustInto(zonedDateTime_target));
        assertEquals(zonedDateTime_target.getOffset(), zonedDateTime_result.getOffset());

        OffsetDateTime offsetDateTime_target = zonedDateTime_target.toOffsetDateTime();
        OffsetDateTime offsetDateTime_result = (OffsetDateTime)(base.adjustInto(offsetDateTime_target));
        assertEquals(base, offsetDateTime_result.getOffset());
    }
}
 
Example 14
Source File: TCKZoneOffset.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_adjustInto_ZonedDateTime() {
    ZoneOffset base = ZoneOffset.ofHoursMinutesSeconds(1, 1, 1);
    for (String zoneId : ZoneId.getAvailableZoneIds()) {
        //Do not change offset of ZonedDateTime after adjustInto()
        ZonedDateTime zonedDateTime_target = ZonedDateTime.of(LocalDate.of(1909, 2, 2), LocalTime.of(10, 10, 10), ZoneId.of(zoneId));
        ZonedDateTime zonedDateTime_result = (ZonedDateTime)(base.adjustInto(zonedDateTime_target));
        assertEquals(zonedDateTime_target.getOffset(), zonedDateTime_result.getOffset());

        OffsetDateTime offsetDateTime_target = zonedDateTime_target.toOffsetDateTime();
        OffsetDateTime offsetDateTime_result = (OffsetDateTime)(base.adjustInto(offsetDateTime_target));
        assertEquals(base, offsetDateTime_result.getOffset());
    }
}
 
Example 15
Source File: DateTimeConverters.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public OffsetDateTime convert(ZonedDateTime source) {
	return source.toOffsetDateTime();
}
 
Example 16
Source File: DateTimeConverters.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public OffsetDateTime convert(ZonedDateTime source) {
	return source.toOffsetDateTime();
}
 
Example 17
Source File: DateTimeConverters.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public OffsetDateTime convert(ZonedDateTime source) {
	return source.toOffsetDateTime();
}
 
Example 18
Source File: DateTimeConverters.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public OffsetDateTime convert(ZonedDateTime source) {
	return source.toOffsetDateTime();
}
 
Example 19
Source File: PDTFactory.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
@Nullable
public static OffsetDateTime createOffsetDateTime (@Nullable final ZonedDateTime aZDT)
{
  return aZDT == null ? null : aZDT.toOffsetDateTime ();
}
 
Example 20
Source File: TimestampColumnOffsetDateTimeMapper.java    From jadira with Apache License 2.0 3 votes vote down vote up
@Override
public OffsetDateTime fromNonNullValue(Timestamp value) {

    ZoneId currentJavaZone = javaZone == null ? getDefaultZoneId() : javaZone;

    ZonedDateTime zonedDateTime = value.toInstant().with(ChronoField.NANO_OF_SECOND, value.getNanos()).atZone(currentJavaZone);
    OffsetDateTime dateTime = zonedDateTime.toOffsetDateTime();
    
    return dateTime;
}