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);
}
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();
}
}
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));
}
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);
}
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);
}
Aggregations