Search in sources :

Example 11 with ZonedDateTime

use of java.time.ZonedDateTime in project hibernate-orm by hibernate.

the class ZonedDateTimeTest method testZoneDateTimeWithHoursZoneOffset.

@Test
public void testZoneDateTimeWithHoursZoneOffset() {
    final ZonedDateTime expectedStartDate = ZonedDateTime.of(2015, 1, 1, 0, 0, 0, 0, ZoneOffset.ofHours(5));
    saveZoneDateTimeEventWithStartDate(expectedStartDate);
    checkSavedZonedDateTimeIsEqual(expectedStartDate);
    compareSavedZonedDateTimeWith(expectedStartDate);
}
Also used : ZonedDateTime(java.time.ZonedDateTime) Test(org.junit.Test)

Example 12 with ZonedDateTime

use of java.time.ZonedDateTime in project hibernate-orm by hibernate.

the class ZonedDateTimeTest method testRetrievingEntityByZoneDateTime.

@Test
public void testRetrievingEntityByZoneDateTime() {
    final ZonedDateTime startDate = ZonedDateTime.of(1, 1, 1, 0, 0, 0, 0, ZoneOffset.ofHours(3));
    saveZoneDateTimeEventWithStartDate(startDate);
    final Session s = openSession();
    try {
        Query query = s.createQuery("from ZonedDateTimeEvent o where o.startDate = :date");
        query.setParameter("date", startDate, ZonedDateTimeType.INSTANCE);
        List<ZonedDateTimeEvent> list = query.list();
        assertThat(list.size(), is(1));
    } finally {
        s.close();
    }
}
Also used : Query(org.hibernate.Query) ZonedDateTime(java.time.ZonedDateTime) Session(org.hibernate.Session) Test(org.junit.Test)

Example 13 with ZonedDateTime

use of java.time.ZonedDateTime in project jdk8u_jdk by JetBrains.

the class TestUmmAlQuraChronology method test_Instant_zonedDateTime.

//-----------------------------------------------------------------------
// zonedDateTime(Instant, ZoneId )
//-----------------------------------------------------------------------
@Test
public void test_Instant_zonedDateTime() {
    OffsetDateTime offsetDateTime = OffsetDateTime.of(2012, 2, 29, 2, 7, 1, 1, OFFSET_PTWO);
    ZonedDateTime zonedDateTime = ZonedDateTime.of(2012, 2, 29, 2, 7, 1, 1, ZONE_RIYADH);
    ChronoZonedDateTime<HijrahDate> result = HijrahChronology.INSTANCE.zonedDateTime(offsetDateTime.toInstant(), offsetDateTime.getOffset());
    assertEquals(result.toLocalDate(), HijrahChronology.INSTANCE.date(1433, 4, 7));
    assertEquals(result.toLocalTime(), LocalTime.of(2, 7, 1, 1));
    result = HijrahChronology.INSTANCE.zonedDateTime(zonedDateTime.toInstant(), zonedDateTime.getOffset());
    assertEquals(result.toLocalDate(), HijrahChronology.INSTANCE.date(1433, 4, 7));
    assertEquals(result.toLocalTime(), LocalTime.of(2, 7, 1, 1));
}
Also used : HijrahDate(java.time.chrono.HijrahDate) OffsetDateTime(java.time.OffsetDateTime) ZonedDateTime(java.time.ZonedDateTime) ChronoZonedDateTime(java.time.chrono.ChronoZonedDateTime) Test(org.testng.annotations.Test)

Example 14 with ZonedDateTime

use of java.time.ZonedDateTime in project jdk8u_jdk by JetBrains.

the class TCKZonedDateTime method test_compareTo_time1.

//-----------------------------------------------------------------------
// compareTo()
//-----------------------------------------------------------------------
@Test
public void test_compareTo_time1() {
    ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, 11, 30, 39, 0, ZONE_0100);
    // a is before b due to time
    ZonedDateTime b = ZonedDateTime.of(2008, 6, 30, 11, 30, 41, 0, ZONE_0100);
    assertEquals(a.compareTo(b) < 0, true);
    assertEquals(b.compareTo(a) > 0, true);
    assertEquals(a.compareTo(a) == 0, true);
    assertEquals(b.compareTo(b) == 0, true);
}
Also used : ZonedDateTime(java.time.ZonedDateTime) Test(org.testng.annotations.Test)

Example 15 with ZonedDateTime

use of java.time.ZonedDateTime in project jdk8u_jdk by JetBrains.

the class TCKZonedDateTime method test_withZoneSameInstant.

//-----------------------------------------------------------------------
// withZoneSameInstant()
//-----------------------------------------------------------------------
@Test
public void test_withZoneSameInstant() {
    ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100);
    ZonedDateTime test = base.withZoneSameInstant(ZONE_0200);
    ZonedDateTime expected = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500.plusHours(1), ZONE_0200);
    assertEquals(test, expected);
}
Also used : ZonedDateTime(java.time.ZonedDateTime) Test(org.testng.annotations.Test)

Aggregations

ZonedDateTime (java.time.ZonedDateTime)1461 Test (org.junit.Test)622 Test (org.testng.annotations.Test)182 LocalDateTime (java.time.LocalDateTime)145 ZoneId (java.time.ZoneId)129 Instant (java.time.Instant)114 ArrayList (java.util.ArrayList)104 Test (org.junit.jupiter.api.Test)96 LocalDate (java.time.LocalDate)90 List (java.util.List)80 DateTimeFormatter (java.time.format.DateTimeFormatter)78 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)76 Date (java.util.Date)66 IOException (java.io.IOException)58 UUID (java.util.UUID)58 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)54 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)53 HashMap (java.util.HashMap)47 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)44 OffsetDateTime (java.time.OffsetDateTime)44