Search in sources :

Example 56 with LocalDate

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

the class TCKDateTimeFormatters method test_parse_basicIsoDate.

//-----------------------------------------------------------------------
@Test
public void test_parse_basicIsoDate() {
    LocalDate expected = LocalDate.of(2008, 6, 3);
    assertEquals(DateTimeFormatter.BASIC_ISO_DATE.parse("20080603", LocalDate::from), expected);
}
Also used : LocalDate(java.time.LocalDate) Test(org.testng.annotations.Test)

Example 57 with LocalDate

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

the class TCKDateTimeParseResolver method test_resolveFourToDateTime.

@Test(dataProvider = "resolveFourToTime")
public void test_resolveFourToDateTime(ResolverStyle style, long hour, long min, long sec, long nano, LocalTime expectedTime, Period excessPeriod) {
    DateTimeFormatter f = new DateTimeFormatterBuilder().parseDefaulting(YEAR, 2012).parseDefaulting(MONTH_OF_YEAR, 6).parseDefaulting(DAY_OF_MONTH, 30).parseDefaulting(HOUR_OF_DAY, hour).parseDefaulting(MINUTE_OF_HOUR, min).parseDefaulting(SECOND_OF_MINUTE, sec).parseDefaulting(NANO_OF_SECOND, nano).toFormatter();
    ResolverStyle[] styles = (style != null ? new ResolverStyle[] { style } : ResolverStyle.values());
    if (expectedTime != null && excessPeriod != null) {
        LocalDate expectedDate = LocalDate.of(2012, 6, 30).plus(excessPeriod);
        for (ResolverStyle s : styles) {
            TemporalAccessor accessor = f.withResolverStyle(s).parse("");
            assertEquals(accessor.query(TemporalQueries.localDate()), expectedDate, "ResolverStyle: " + s);
            assertEquals(accessor.query(TemporalQueries.localTime()), expectedTime, "ResolverStyle: " + s);
            assertEquals(accessor.query(DateTimeFormatter.parsedExcessDays()), Period.ZERO, "ResolverStyle: " + s);
        }
    }
}
Also used : TemporalAccessor(java.time.temporal.TemporalAccessor) ResolverStyle(java.time.format.ResolverStyle) DateTimeFormatter(java.time.format.DateTimeFormatter) LocalDate(java.time.LocalDate) ChronoLocalDate(java.time.chrono.ChronoLocalDate) DateTimeFormatterBuilder(java.time.format.DateTimeFormatterBuilder) Test(org.testng.annotations.Test)

Example 58 with LocalDate

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

the class TCKDateTimeParseResolver method test_fieldResolvesToChronoLocalDate_noOverrideChrono_matches.

//-------------------------------------------------------------------------
@Test
public void test_fieldResolvesToChronoLocalDate_noOverrideChrono_matches() {
    LocalDate ldt = LocalDate.of(2010, 6, 30);
    DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(ldt)).toFormatter();
    TemporalAccessor accessor = f.parse("1234567890");
    assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(2010, 6, 30));
    assertEquals(accessor.query(TemporalQueries.localTime()), null);
    assertEquals(accessor.query(TemporalQueries.chronology()), IsoChronology.INSTANCE);
}
Also used : TemporalAccessor(java.time.temporal.TemporalAccessor) LocalDate(java.time.LocalDate) ChronoLocalDate(java.time.chrono.ChronoLocalDate) DateTimeFormatter(java.time.format.DateTimeFormatter) DateTimeFormatterBuilder(java.time.format.DateTimeFormatterBuilder) Test(org.testng.annotations.Test)

Example 59 with LocalDate

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

the class TestLocalDateTime method test_comparisons_LocalDateTime.

void test_comparisons_LocalDateTime(LocalDate[] localDates, LocalTime... localTimes) {
    LocalDateTime[] localDateTimes = new LocalDateTime[localDates.length * localTimes.length];
    int i = 0;
    for (LocalDate localDate : localDates) {
        for (LocalTime localTime : localTimes) {
            localDateTimes[i++] = LocalDateTime.of(localDate, localTime);
        }
    }
    doTest_comparisons_LocalDateTime(localDateTimes);
}
Also used : LocalDateTime(java.time.LocalDateTime) LocalTime(java.time.LocalTime) LocalDate(java.time.LocalDate)

Example 60 with LocalDate

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

the class TestLocalDate method test_withDayOfMonth_noChange_same.

@Test
public void test_withDayOfMonth_noChange_same() {
    LocalDate t = TEST_2007_07_15.withDayOfMonth(15);
    assertSame(t, TEST_2007_07_15);
}
Also used : LocalDate(java.time.LocalDate) Test(org.testng.annotations.Test)

Aggregations

LocalDate (java.time.LocalDate)1513 Test (org.junit.Test)472 Test (org.testng.annotations.Test)372 LocalDateTime (java.time.LocalDateTime)155 LocalTime (java.time.LocalTime)126 Date (java.util.Date)99 DateTimeFormatter (java.time.format.DateTimeFormatter)96 Ignore (org.junit.Ignore)94 ArrayList (java.util.ArrayList)87 BigDecimal (java.math.BigDecimal)69 Instant (java.time.Instant)56 ZonedDateTime (java.time.ZonedDateTime)55 Test (org.junit.jupiter.api.Test)54 List (java.util.List)50 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)46 HashMap (java.util.HashMap)44 Member (cz.metacentrum.perun.core.api.Member)41 ZoneId (java.time.ZoneId)40 TemporalField (java.time.temporal.TemporalField)40 Attribute (cz.metacentrum.perun.core.api.Attribute)39