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