Java Code Examples for java.time.MonthDay#of()

The following examples show how to use java.time.MonthDay#of() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TCKMonthDay.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider="sampleDates")
public void test_get(int m, int d) {
    MonthDay a = MonthDay.of(m, d);
    assertEquals(a.getMonth(), Month.of(m));
    assertEquals(a.getMonthValue(), m);
    assertEquals(a.getDayOfMonth(), d);
}
 
Example 2
Source File: TCKMonthDay.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_equals() {
    MonthDay a = MonthDay.of(1, 1);
    MonthDay b = MonthDay.of(1, 1);
    MonthDay c = MonthDay.of(2, 1);
    MonthDay d = MonthDay.of(1, 2);

    assertEquals(a.equals(a), true);
    assertEquals(a.equals(b), true);
    assertEquals(a.equals(c), false);
    assertEquals(a.equals(d), false);

    assertEquals(b.equals(a), true);
    assertEquals(b.equals(b), true);
    assertEquals(b.equals(c), false);
    assertEquals(b.equals(d), false);

    assertEquals(c.equals(a), false);
    assertEquals(c.equals(b), false);
    assertEquals(c.equals(c), true);
    assertEquals(c.equals(d), false);

    assertEquals(d.equals(a), false);
    assertEquals(d.equals(b), false);
    assertEquals(d.equals(c), false);
    assertEquals(d.equals(d), true);
}
 
Example 3
Source File: TCKMonthDay.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name="goodParseData")
Object[][] provider_goodParseData() {
    return new Object[][] {
            {"--01-01", MonthDay.of(1, 1)},
            {"--01-31", MonthDay.of(1, 31)},
            {"--02-01", MonthDay.of(2, 1)},
            {"--02-29", MonthDay.of(2, 29)},
            {"--03-01", MonthDay.of(3, 1)},
            {"--03-31", MonthDay.of(3, 31)},
            {"--04-01", MonthDay.of(4, 1)},
            {"--04-30", MonthDay.of(4, 30)},
            {"--05-01", MonthDay.of(5, 1)},
            {"--05-31", MonthDay.of(5, 31)},
            {"--06-01", MonthDay.of(6, 1)},
            {"--06-30", MonthDay.of(6, 30)},
            {"--07-01", MonthDay.of(7, 1)},
            {"--07-31", MonthDay.of(7, 31)},
            {"--08-01", MonthDay.of(8, 1)},
            {"--08-31", MonthDay.of(8, 31)},
            {"--09-01", MonthDay.of(9, 1)},
            {"--09-30", MonthDay.of(9, 30)},
            {"--10-01", MonthDay.of(10, 1)},
            {"--10-31", MonthDay.of(10, 31)},
            {"--11-01", MonthDay.of(11, 1)},
            {"--11-30", MonthDay.of(11, 30)},
            {"--12-01", MonthDay.of(12, 1)},
            {"--12-31", MonthDay.of(12, 31)},
    };
}
 
Example 4
Source File: TCKMonthDay.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_adjustDate_equal() {
    MonthDay test = MonthDay.of(6, 30);
    LocalDate date = LocalDate.of(2007, 6, 30);
    assertEquals(test.adjustInto(date), date);
}
 
Example 5
Source File: TCKMonthDay.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_isValidYear_june() {
    MonthDay test = MonthDay.of(6, 30);
    assertEquals(test.isValidYear(2007), true);
}
 
Example 6
Source File: TCKMonthDay.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void test_factory_intMonth_dayTooHigh() {
    MonthDay.of(Month.JANUARY, 32);
}
 
Example 7
Source File: TCKMonthDay.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_withDayOfMonth_noChangeEqual() {
    MonthDay test = MonthDay.of(6, 30);
    assertEquals(test.withDayOfMonth(30), test);
}
 
Example 8
Source File: TestMonthDay.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_with_Month_noChangeSame() {
    MonthDay test = MonthDay.of(6, 30);
    assertSame(test.with(Month.JUNE), test);
}
 
Example 9
Source File: TestMonthDay.java    From j2objc with Apache License 2.0 4 votes vote down vote up
@Test
public void test_with_Month_noChangeSame() {
    MonthDay test = MonthDay.of(6, 30);
    assertSame(test.with(Month.JUNE), test);
}
 
Example 10
Source File: TCKMonthDay.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_isValidYear_febLeap() {
    MonthDay test = MonthDay.of(2, 29);
    assertEquals(test.isValidYear(2008), true);
}
 
Example 11
Source File: TestMonthDay.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_with_Month_noChangeSame() {
    MonthDay test = MonthDay.of(6, 30);
    assertSame(test.with(Month.JUNE), test);
}
 
Example 12
Source File: TCKMonthDay.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void factory_intMonth_nullMonth() {
    MonthDay.of(null, 15);
}
 
Example 13
Source File: TCKMonthDay.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void test_factory_ints_monthTooHigh() {
    MonthDay.of(13, 1);
}
 
Example 14
Source File: TCKMonthDay.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void test_factory_ints_dayTooLow() {
    MonthDay.of(1, 0);
}
 
Example 15
Source File: TCKMonthDay.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void test_factory_intMonth_dayTooHigh() {
    MonthDay.of(Month.JANUARY, 32);
}
 
Example 16
Source File: TCKMonthDay.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_adjustDate() {
    MonthDay test = MonthDay.of(6, 30);
    LocalDate date = LocalDate.of(2007, 1, 1);
    assertEquals(test.adjustInto(date), LocalDate.of(2007, 6, 30));
}
 
Example 17
Source File: TCKMonthDay.java    From j2objc with Apache License 2.0 4 votes vote down vote up
@Test
public void test_isValidYear_june() {
    MonthDay test = MonthDay.of(6, 30);
    assertEquals(test.isValidYear(2007), true);
}
 
Example 18
Source File: TCKMonthDay.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void test_factory_ints_dayTooHigh() {
    MonthDay.of(1, 32);
}
 
Example 19
Source File: TCKMonthDay.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_with_Month_noChangeEqual() {
    MonthDay test = MonthDay.of(6, 30);
    assertEquals(test.with(Month.JUNE), test);
}
 
Example 20
Source File: TestMonthDay.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_with_Month_noChangeSame() {
    MonthDay test = MonthDay.of(6, 30);
    assertSame(test.with(Month.JUNE), test);
}