use of java.time.MonthDay in project jdk8u_jdk by JetBrains.
the class TestMonthDay method doTest_comparisons_MonthDay.
void doTest_comparisons_MonthDay(MonthDay... localDates) {
for (int i = 0; i < localDates.length; i++) {
MonthDay a = localDates[i];
for (int j = 0; j < localDates.length; j++) {
MonthDay 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.MonthDay in project lucene-solr by apache.
the class TemporalEvaluatorsTest method testLimitedFunctions.
@Test
public void testLimitedFunctions() throws Exception {
MonthDay monthDay = MonthDay.of(12, 5);
testFunction("month(a)", monthDay, 12);
testFunction("day(a)", monthDay, 5);
try {
testFunction("year(a)", monthDay, 2017);
assertTrue(false);
} catch (IOException e) {
assertEquals("It is not possible to call 'year' function on java.time.MonthDay", e.getMessage());
}
YearMonth yearMonth = YearMonth.of(2018, 4);
testFunction("month(a)", yearMonth, 4);
testFunction("year(a)", yearMonth, 2018);
try {
testFunction("day(a)", yearMonth, 5);
assertTrue(false);
} catch (IOException e) {
assertEquals("It is not possible to call 'day' function on java.time.YearMonth", e.getMessage());
}
}
use of java.time.MonthDay in project jdk8u_jdk by JetBrains.
the class TestMonthDay method test_withMonth_int_noChangeSame.
@Test
public void test_withMonth_int_noChangeSame() {
MonthDay test = MonthDay.of(6, 30);
assertSame(test.withMonth(6), test);
}
use of java.time.MonthDay in project jdk8u_jdk by JetBrains.
the class TestMonthDay method test_withDayOfMonth_noChangeSame.
@Test
public void test_withDayOfMonth_noChangeSame() {
MonthDay test = MonthDay.of(6, 30);
assertSame(test.withDayOfMonth(30), test);
}
use of java.time.MonthDay in project jdk8u_jdk by JetBrains.
the class TCKMonthDay method now_Clock.
//-----------------------------------------------------------------------
// now(Clock)
//-----------------------------------------------------------------------
@Test
public void now_Clock() {
Instant instant = LocalDateTime.of(2010, 12, 31, 0, 0).toInstant(ZoneOffset.UTC);
Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
MonthDay test = MonthDay.now(clock);
assertEquals(test.getMonth(), Month.DECEMBER);
assertEquals(test.getDayOfMonth(), 31);
}
Aggregations