Search in sources :

Example 66 with ZonedDateTime

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

the class TCKDuration method factory_between_TemporalTemporal_mixedTypes.

@Test
public void factory_between_TemporalTemporal_mixedTypes() {
    Instant start = Instant.ofEpochSecond(1);
    ZonedDateTime end = Instant.ofEpochSecond(4).atZone(ZoneOffset.UTC);
    assertEquals(Duration.between(start, end), Duration.ofSeconds(3));
}
Also used : ZonedDateTime(java.time.ZonedDateTime) Instant(java.time.Instant) Test(org.testng.annotations.Test)

Example 67 with ZonedDateTime

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

the class TCKChronoZonedDateTimeSerialization method test_ChronoZonedDateTimeSerialization.

//-----------------------------------------------------------------------
// Test Serialization of ISO via chrono API
//-----------------------------------------------------------------------
@Test(dataProvider = "calendars")
public void test_ChronoZonedDateTimeSerialization(Chronology chrono) throws Exception {
    ZonedDateTime ref = LocalDate.of(2013, 1, 5).atTime(12, 1, 2, 3).atZone(ZoneId.of("GMT+01:23"));
    ChronoZonedDateTime<?> original = chrono.date(ref).atTime(ref.toLocalTime()).atZone(ref.getZone());
    assertSerializable(original);
}
Also used : ZonedDateTime(java.time.ZonedDateTime) ChronoZonedDateTime(java.time.chrono.ChronoZonedDateTime) Test(org.testng.annotations.Test) AbstractTCKTest(tck.java.time.AbstractTCKTest)

Example 68 with ZonedDateTime

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

the class TCKDateTimeFormatter method data_format_withZone_withChronology.

//-----------------------------------------------------------------------
// format
//-----------------------------------------------------------------------
@DataProvider(name = "formatWithZoneWithChronology")
Object[][] data_format_withZone_withChronology() {
    YearMonth ym = YearMonth.of(2008, 6);
    LocalDate ld = LocalDate.of(2008, 6, 30);
    LocalTime lt = LocalTime.of(11, 30);
    LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 11, 30);
    OffsetTime ot = OffsetTime.of(LocalTime.of(11, 30), OFFSET_PONE);
    OffsetDateTime odt = OffsetDateTime.of(LocalDateTime.of(2008, 6, 30, 11, 30), OFFSET_PONE);
    ZonedDateTime zdt = ZonedDateTime.of(LocalDateTime.of(2008, 6, 30, 11, 30), ZONE_PARIS);
    ChronoZonedDateTime<ThaiBuddhistDate> thaiZdt = ThaiBuddhistChronology.INSTANCE.zonedDateTime(zdt);
    Instant instant = Instant.ofEpochSecond(3600);
    return new Object[][] { { null, null, DayOfWeek.MONDAY, "::::" }, { null, null, ym, "2008::::ISO" }, { null, null, ld, "2008::::ISO" }, { null, null, lt, ":11:::" }, { null, null, ldt, "2008:11:::ISO" }, { null, null, ot, ":11:+01:00::" }, { null, null, odt, "2008:11:+01:00::ISO" }, { null, null, zdt, "2008:11:+02:00:Europe/Paris:ISO" }, { null, null, instant, "::::" }, { IsoChronology.INSTANCE, null, DayOfWeek.MONDAY, "::::ISO" }, { IsoChronology.INSTANCE, null, ym, "2008::::ISO" }, { IsoChronology.INSTANCE, null, ld, "2008::::ISO" }, { IsoChronology.INSTANCE, null, lt, ":11:::ISO" }, { IsoChronology.INSTANCE, null, ldt, "2008:11:::ISO" }, { IsoChronology.INSTANCE, null, ot, ":11:+01:00::ISO" }, { IsoChronology.INSTANCE, null, odt, "2008:11:+01:00::ISO" }, { IsoChronology.INSTANCE, null, zdt, "2008:11:+02:00:Europe/Paris:ISO" }, { IsoChronology.INSTANCE, null, instant, "::::ISO" }, { null, ZONE_PARIS, DayOfWeek.MONDAY, ":::Europe/Paris:" }, { null, ZONE_PARIS, ym, "2008:::Europe/Paris:ISO" }, { null, ZONE_PARIS, ld, "2008:::Europe/Paris:ISO" }, { null, ZONE_PARIS, lt, ":11::Europe/Paris:" }, { null, ZONE_PARIS, ldt, "2008:11::Europe/Paris:ISO" }, { null, ZONE_PARIS, ot, ":11:+01:00:Europe/Paris:" }, { null, ZONE_PARIS, odt, "2008:12:+02:00:Europe/Paris:ISO" }, { null, ZONE_PARIS, zdt, "2008:11:+02:00:Europe/Paris:ISO" }, { null, ZONE_PARIS, instant, "1970:02:+01:00:Europe/Paris:ISO" }, { null, OFFSET_PTHREE, DayOfWeek.MONDAY, ":::+03:00:" }, { null, OFFSET_PTHREE, ym, "2008:::+03:00:ISO" }, { null, OFFSET_PTHREE, ld, "2008:::+03:00:ISO" }, { null, OFFSET_PTHREE, lt, ":11::+03:00:" }, { null, OFFSET_PTHREE, ldt, "2008:11::+03:00:ISO" }, // offset and zone clash
    { null, OFFSET_PTHREE, ot, null }, { null, OFFSET_PTHREE, odt, "2008:13:+03:00:+03:00:ISO" }, { null, OFFSET_PTHREE, zdt, "2008:12:+03:00:+03:00:ISO" }, { null, OFFSET_PTHREE, instant, "1970:04:+03:00:+03:00:ISO" }, // not a complete date
    { ThaiBuddhistChronology.INSTANCE, null, DayOfWeek.MONDAY, null }, // not a complete date
    { ThaiBuddhistChronology.INSTANCE, null, ym, null }, { ThaiBuddhistChronology.INSTANCE, null, ld, "2551::::ThaiBuddhist" }, { ThaiBuddhistChronology.INSTANCE, null, lt, ":11:::ThaiBuddhist" }, { ThaiBuddhistChronology.INSTANCE, null, ldt, "2551:11:::ThaiBuddhist" }, { ThaiBuddhistChronology.INSTANCE, null, ot, ":11:+01:00::ThaiBuddhist" }, { ThaiBuddhistChronology.INSTANCE, null, odt, "2551:11:+01:00::ThaiBuddhist" }, { ThaiBuddhistChronology.INSTANCE, null, zdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist" }, { ThaiBuddhistChronology.INSTANCE, null, instant, "::::ThaiBuddhist" }, // not a complete date
    { ThaiBuddhistChronology.INSTANCE, null, DayOfWeek.MONDAY, null }, // not a complete date
    { ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, ym, null }, { ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, ld, "2551:::Europe/Paris:ThaiBuddhist" }, { ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, lt, ":11::Europe/Paris:ThaiBuddhist" }, { ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, ldt, "2551:11::Europe/Paris:ThaiBuddhist" }, { ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, ot, ":11:+01:00:Europe/Paris:ThaiBuddhist" }, { ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, odt, "2551:12:+02:00:Europe/Paris:ThaiBuddhist" }, { ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, zdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist" }, { ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, instant, "2513:02:+01:00:Europe/Paris:ThaiBuddhist" }, { null, ZONE_PARIS, thaiZdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist" }, { ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, thaiZdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist" }, { IsoChronology.INSTANCE, ZONE_PARIS, thaiZdt, "2008:11:+02:00:Europe/Paris:ISO" } };
}
Also used : LocalDateTime(java.time.LocalDateTime) ThaiBuddhistDate(java.time.chrono.ThaiBuddhistDate) YearMonth(java.time.YearMonth) LocalTime(java.time.LocalTime) OffsetDateTime(java.time.OffsetDateTime) ZonedDateTime(java.time.ZonedDateTime) ChronoZonedDateTime(java.time.chrono.ChronoZonedDateTime) OffsetTime(java.time.OffsetTime) Instant(java.time.Instant) LocalDate(java.time.LocalDate) DataProvider(org.testng.annotations.DataProvider)

Example 69 with ZonedDateTime

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

the class TCKDateTimeFormatter method test_parseBest_firstOption.

//-----------------------------------------------------------------------
@Test
public void test_parseBest_firstOption() throws Exception {
    DateTimeFormatter test = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm[XXX]");
    TemporalAccessor result = test.parseBest("2011-06-30 12:30+03:00", ZonedDateTime::from, LocalDateTime::from);
    LocalDateTime ldt = LocalDateTime.of(2011, 6, 30, 12, 30);
    assertEquals(result, ZonedDateTime.of(ldt, ZoneOffset.ofHours(3)));
}
Also used : LocalDateTime(java.time.LocalDateTime) TemporalAccessor(java.time.temporal.TemporalAccessor) ZonedDateTime(java.time.ZonedDateTime) ChronoZonedDateTime(java.time.chrono.ChronoZonedDateTime) DateTimeFormatter(java.time.format.DateTimeFormatter) Test(org.testng.annotations.Test)

Example 70 with ZonedDateTime

use of java.time.ZonedDateTime in project geode by apache.

the class ExportLogsDUnitTest method startAndEndDateCanIncludeLogs.

@Test
public void startAndEndDateCanIncludeLogs() throws Exception {
    ZonedDateTime now = LocalDateTime.now().atZone(ZoneId.systemDefault());
    ZonedDateTime yesterday = now.minusDays(1);
    ZonedDateTime tomorrow = now.plusDays(1);
    DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(ONLY_DATE_FORMAT);
    CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs");
    commandStringBuilder.addOption("start-time", dateTimeFormatter.format(yesterday));
    commandStringBuilder.addOption("end-time", dateTimeFormatter.format(tomorrow));
    commandStringBuilder.addOption("log-level", "debug");
    gfshConnector.executeAndVerifyCommand(commandStringBuilder.toString());
    Set<String> acceptedLogLevels = Stream.of("info", "error", "debug").collect(toSet());
    verifyZipFileContents(acceptedLogLevels);
}
Also used : ZonedDateTime(java.time.ZonedDateTime) CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) DateTimeFormatter(java.time.format.DateTimeFormatter) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

ZonedDateTime (java.time.ZonedDateTime)1375 Test (org.junit.Test)570 Test (org.testng.annotations.Test)182 LocalDateTime (java.time.LocalDateTime)136 ZoneId (java.time.ZoneId)122 Instant (java.time.Instant)112 ArrayList (java.util.ArrayList)102 Test (org.junit.jupiter.api.Test)93 LocalDate (java.time.LocalDate)84 DateTimeFormatter (java.time.format.DateTimeFormatter)77 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)76 List (java.util.List)75 Date (java.util.Date)63 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)46 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)44 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)43