Search in sources :

Example 41 with LocalDate

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

the class TCKLocalDate method test_periodUntil_LocalDate.

@Test(dataProvider = "until")
public void test_periodUntil_LocalDate(int y1, int m1, int d1, int y2, int m2, int d2, int ye, int me, int de) {
    LocalDate start = LocalDate.of(y1, m1, d1);
    LocalDate end = LocalDate.of(y2, m2, d2);
    Period test = start.until(end);
    assertEquals(test.getYears(), ye);
    assertEquals(test.getMonths(), me);
    assertEquals(test.getDays(), de);
}
Also used : MockSimplePeriod(test.java.time.MockSimplePeriod) Period(java.time.Period) LocalDate(java.time.LocalDate) Test(org.testng.annotations.Test)

Example 42 with LocalDate

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

the class TCKLocalDate method now_Clock_minYear.

@Test
public void now_Clock_minYear() {
    Clock clock = Clock.fixed(MIN_INSTANT, ZoneOffset.UTC);
    LocalDate test = LocalDate.now(clock);
    assertEquals(test, MIN_DATE);
}
Also used : Clock(java.time.Clock) LocalDate(java.time.LocalDate) Test(org.testng.annotations.Test)

Example 43 with LocalDate

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

the class TCKLocalDate method doTest_comparisons_LocalDate.

void doTest_comparisons_LocalDate(LocalDate... localDates) {
    for (int i = 0; i < localDates.length; i++) {
        LocalDate a = localDates[i];
        for (int j = 0; j < localDates.length; j++) {
            LocalDate b = localDates[j];
            if (i < j) {
                assertTrue(a.compareTo(b) < 0, a + " <=> " + b);
                assertEquals(a.isBefore(b), true, a + " <=> " + b);
                assertEquals(a.isAfter(b), false, a + " <=> " + b);
                assertEquals(a.equals(b), false, a + " <=> " + b);
            } else if (i > j) {
                assertTrue(a.compareTo(b) > 0, a + " <=> " + b);
                assertEquals(a.isBefore(b), false, a + " <=> " + b);
                assertEquals(a.isAfter(b), true, a + " <=> " + b);
                assertEquals(a.equals(b), false, a + " <=> " + b);
            } else {
                assertEquals(a.compareTo(b), 0, a + " <=> " + b);
                assertEquals(a.isBefore(b), false, a + " <=> " + b);
                assertEquals(a.isAfter(b), false, a + " <=> " + b);
                assertEquals(a.equals(b), true, a + " <=> " + b);
            }
        }
    }
}
Also used : LocalDate(java.time.LocalDate)

Example 44 with LocalDate

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

the class TCKLocalDate method now_Clock_allSecsInDay_beforeEpoch.

@Test
public void now_Clock_allSecsInDay_beforeEpoch() {
    for (int i = -1; i >= -(2 * 24 * 60 * 60); i--) {
        Instant instant = Instant.ofEpochSecond(i);
        Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
        LocalDate test = LocalDate.now(clock);
        assertEquals(test.getYear(), 1969);
        assertEquals(test.getMonth(), Month.DECEMBER);
        assertEquals(test.getDayOfMonth(), (i >= -24 * 60 * 60 ? 31 : 30));
    }
}
Also used : Instant(java.time.Instant) Clock(java.time.Clock) LocalDate(java.time.LocalDate) Test(org.testng.annotations.Test)

Example 45 with LocalDate

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

the class TCKLocalDate method test_atTime_int_int_hourTooBig.

@Test(expectedExceptions = DateTimeException.class)
public void test_atTime_int_int_hourTooBig() {
    LocalDate t = LocalDate.of(2008, 6, 30);
    t.atTime(24, 30);
}
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