Search in sources :

Example 6 with ZonedDateTime

use of java.time.ZonedDateTime in project jetty.project by eclipse.

the class RolloverFileOutputStreamTest method assertSequence.

private void assertSequence(ZonedDateTime midnight, Object[][] expected) {
    ZonedDateTime nextEvent = midnight;
    for (int i = 0; i < expected.length; i++) {
        long lastMs = nextEvent.toInstant().toEpochMilli();
        nextEvent = RolloverFileOutputStream.nextMidnight(nextEvent);
        assertThat("Next Event", toString(nextEvent), is(expected[i][0]));
        long duration = (nextEvent.toInstant().toEpochMilli() - lastMs);
        assertThat("Duration to next event", duration, is((long) expected[i][1]));
    }
}
Also used : ZonedDateTime(java.time.ZonedDateTime)

Example 7 with ZonedDateTime

use of java.time.ZonedDateTime in project jetty.project by eclipse.

the class RolloverFileOutputStreamTest method testMidnightRolloverCalc_Sydney_DST_End.

@Test
public void testMidnightRolloverCalc_Sydney_DST_End() {
    ZoneId zone = toZoneId("Australia/Sydney");
    ZonedDateTime initialDate = toDateTime("2016.04.02-11:22:33.0 AM AEDT", zone);
    ZonedDateTime midnight = RolloverFileOutputStream.toMidnight(initialDate, zone);
    assertThat("Midnight", toString(midnight), is("2016.04.02-12:00:00.0 AM AEDT"));
    Object[][] expected = { { "2016.04.03-12:00:00.0 AM AEDT", 86_400_000L }, // The long day
    { "2016.04.04-12:00:00.0 AM AEST", 90_000_000L }, { "2016.04.05-12:00:00.0 AM AEST", 86_400_000L }, { "2016.04.06-12:00:00.0 AM AEST", 86_400_000L }, { "2016.04.07-12:00:00.0 AM AEST", 86_400_000L } };
    assertSequence(midnight, expected);
}
Also used : ZoneId(java.time.ZoneId) ZonedDateTime(java.time.ZonedDateTime) Test(org.junit.Test)

Example 8 with ZonedDateTime

use of java.time.ZonedDateTime in project jetty.project by eclipse.

the class RolloverFileOutputStreamTest method testMidnightRolloverCalc_PST_DST_Start.

@Test
public void testMidnightRolloverCalc_PST_DST_Start() {
    ZoneId zone = toZoneId("PST");
    ZonedDateTime initialDate = toDateTime("2016.03.11-01:23:45.0 PM PST", zone);
    ZonedDateTime midnight = RolloverFileOutputStream.toMidnight(initialDate, zone);
    assertThat("Midnight", toString(midnight), is("2016.03.11-12:00:00.0 AM PST"));
    Object[][] expected = { { "2016.03.12-12:00:00.0 AM PST", 86_400_000L }, { "2016.03.13-12:00:00.0 AM PST", 86_400_000L }, // the short day
    { "2016.03.14-12:00:00.0 AM PDT", 82_800_000L }, { "2016.03.15-12:00:00.0 AM PDT", 86_400_000L }, { "2016.03.16-12:00:00.0 AM PDT", 86_400_000L } };
    assertSequence(midnight, expected);
}
Also used : ZoneId(java.time.ZoneId) ZonedDateTime(java.time.ZonedDateTime) Test(org.junit.Test)

Example 9 with ZonedDateTime

use of java.time.ZonedDateTime in project jetty.project by eclipse.

the class RolloverFileOutputStreamTest method testMidnightRolloverCalc_PST_DST_End.

@Test
public void testMidnightRolloverCalc_PST_DST_End() {
    ZoneId zone = toZoneId("PST");
    ZonedDateTime initialDate = toDateTime("2016.11.04-11:22:33.0 AM PDT", zone);
    ZonedDateTime midnight = RolloverFileOutputStream.toMidnight(initialDate, zone);
    assertThat("Midnight", toString(midnight), is("2016.11.04-12:00:00.0 AM PDT"));
    Object[][] expected = { { "2016.11.05-12:00:00.0 AM PDT", 86_400_000L }, { "2016.11.06-12:00:00.0 AM PDT", 86_400_000L }, // the long day
    { "2016.11.07-12:00:00.0 AM PST", 90_000_000L }, { "2016.11.08-12:00:00.0 AM PST", 86_400_000L }, { "2016.11.09-12:00:00.0 AM PST", 86_400_000L } };
    assertSequence(midnight, expected);
}
Also used : ZoneId(java.time.ZoneId) ZonedDateTime(java.time.ZonedDateTime) Test(org.junit.Test)

Example 10 with ZonedDateTime

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

the class ZonedDateTimeTest method testZoneDateTimeWithUTCZoneOffset.

@Test
public void testZoneDateTimeWithUTCZoneOffset() {
    final ZonedDateTime expectedStartDate = ZonedDateTime.of(1, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC);
    saveZoneDateTimeEventWithStartDate(expectedStartDate);
    checkSavedZonedDateTimeIsEqual(expectedStartDate);
    compareSavedZonedDateTimeWith(expectedStartDate);
}
Also used : ZonedDateTime(java.time.ZonedDateTime) Test(org.junit.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