类java.time.MonthDay源码实例Demo

下面列出了怎么用java.time.MonthDay的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: openjdk-jdk8u   文件: TCKMonthDay.java
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);
            }
        }
    }
}
 
源代码2 项目: jdk8u-jdk   文件: TestMonthDay.java
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);
            }
        }
    }
}
 
源代码3 项目: openjdk-8-source   文件: TestMonthDay.java
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);
            }
        }
    }
}
 
源代码4 项目: TencentKona-8   文件: TCKMonthDaySerialization.java
@Test
public void test_serialization_format() throws Exception {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try (DataOutputStream dos = new DataOutputStream(baos) ) {
        dos.writeByte(13);       // java.time.temporal.Ser.MONTH_DAY_TYPE
        dos.writeByte(9);
        dos.writeByte(16);
    }
    byte[] bytes = baos.toByteArray();
    assertSerializedBySer(MonthDay.of(9, 16), bytes);
}
 
源代码5 项目: openjdk-jdk9   文件: TCKMonthDay.java
@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)},
    };
}
 
源代码6 项目: openjdk-8-source   文件: TCKMonthDay.java
@Test(dataProvider="badParseData", expectedExceptions=DateTimeParseException.class)
public void factory_parse_fail(String text, int pos) {
    try {
        MonthDay.parse(text);
        fail(String.format("Parse should have failed for %s at position %d", text, pos));
    }
    catch (DateTimeParseException ex) {
        assertEquals(ex.getParsedString(), text);
        assertEquals(ex.getErrorIndex(), pos);
        throw ex;
    }
}
 
源代码7 项目: dragonwell8_jdk   文件: TCKMonthDay.java
@Test
public void test_hashCode_unique() {
    int leapYear = 2008;
    Set<Integer> uniques = new HashSet<Integer>(366);
    for (int i = 1; i <= 12; i++) {
        for (int j = 1; j <= 31; j++) {
            if (YearMonth.of(leapYear, i).isValidDay(j)) {
                assertTrue(uniques.add(MonthDay.of(i, j).hashCode()));
            }
        }
    }
}
 
源代码8 项目: hottub   文件: TestDateTimeFormatter.java
@Test
public void test_parse_errorMessage() throws Exception {
    assertGoodErrorDate(DayOfWeek::from, "DayOfWeek");
    assertGoodErrorDate(Month::from, "Month");
    assertGoodErrorDate(YearMonth::from, "YearMonth");
    assertGoodErrorDate(MonthDay::from, "MonthDay");
    assertGoodErrorDate(LocalDate::from, "LocalDate");
    assertGoodErrorDate(LocalTime::from, "LocalTime");
    assertGoodErrorDate(LocalDateTime::from, "LocalDateTime");
    assertGoodErrorDate(OffsetTime::from, "OffsetTime");
    assertGoodErrorDate(OffsetDateTime::from, "OffsetDateTime");
    assertGoodErrorDate(ZonedDateTime::from, "ZonedDateTime");
    assertGoodErrorDate(Instant::from, "Instant");
    assertGoodErrorDate(ZoneOffset::from, "ZoneOffset");
    assertGoodErrorDate(ZoneId::from, "ZoneId");
    assertGoodErrorDate(ThaiBuddhistChronology.INSTANCE::date, "");

    assertGoodErrorTime(DayOfWeek::from, "DayOfWeek");
    assertGoodErrorTime(Month::from, "Month");
    assertGoodErrorTime(Year::from, "Year");
    assertGoodErrorTime(YearMonth::from, "YearMonth");
    assertGoodErrorTime(MonthDay::from, "MonthDay");
    assertGoodErrorTime(LocalDate::from, "LocalDate");
    assertGoodErrorTime(LocalTime::from, "LocalTime");
    assertGoodErrorTime(LocalDateTime::from, "LocalDateTime");
    assertGoodErrorTime(OffsetTime::from, "OffsetTime");
    assertGoodErrorTime(OffsetDateTime::from, "OffsetDateTime");
    assertGoodErrorTime(ZonedDateTime::from, "ZonedDateTime");
    assertGoodErrorTime(Instant::from, "Instant");
    assertGoodErrorTime(ZoneOffset::from, "ZoneOffset");
    assertGoodErrorTime(ZoneId::from, "ZoneId");
    assertGoodErrorTime(ThaiBuddhistChronology.INSTANCE::date, "");
}
 
源代码9 项目: dragonwell8_jdk   文件: TestIsoWeekFields.java
@Test(dataProvider = "fields")
public void test_WOWBY_isSupportedBy(TemporalField weekField, TemporalField yearField) {
    assertEquals(weekField.isSupportedBy(LocalTime.NOON), false);
    assertEquals(weekField.isSupportedBy(MonthDay.of(2, 1)), false);
    assertEquals(weekField.isSupportedBy(LocalDate.MIN), true);
    assertEquals(weekField.isSupportedBy(OffsetDateTime.MAX), true);
}
 
源代码10 项目: openjdk-jdk9   文件: TCKYear.java
@DataProvider(name="atMonthDay")
Object[][] data_atMonthDay() {
    return new Object[][] {
            {Year.of(2008), MonthDay.of(6, 30), LocalDate.of(2008, 6, 30)},
            {Year.of(2008), MonthDay.of(2, 29), LocalDate.of(2008, 2, 29)},
            {Year.of(2009), MonthDay.of(2, 29), LocalDate.of(2009, 2, 28)},
    };
}
 
源代码11 项目: jdk8u-dev-jdk   文件: TestIsoWeekFields.java
@Test(dataProvider = "fields")
public void test_WOWBY_isSupportedBy(TemporalField weekField, TemporalField yearField) {
    assertEquals(weekField.isSupportedBy(LocalTime.NOON), false);
    assertEquals(weekField.isSupportedBy(MonthDay.of(2, 1)), false);
    assertEquals(weekField.isSupportedBy(LocalDate.MIN), true);
    assertEquals(weekField.isSupportedBy(OffsetDateTime.MAX), true);
}
 
@Override
public EnhancedType<MonthDay> type() {
    return EnhancedType.of(MonthDay.class);
}
 
源代码13 项目: tinkerpop   文件: JavaTimeSerializersV3d0.java
public MonthDayJacksonDeserializer() {
    super(MonthDay.class);
}
 
源代码14 项目: jdk8u_jdk   文件: TCKMonthDay.java
@Test
public void test_isValidYear_june() {
    MonthDay test = MonthDay.of(6, 30);
    assertEquals(test.isValidYear(2007), true);
}
 
源代码15 项目: openjdk-8   文件: TCKMonthDay.java
@Test(expectedExceptions=NullPointerException.class)
public void test_factory_CalendricalObject_null() {
    MonthDay.from((TemporalAccessor) null);
}
 
源代码16 项目: jdk8u-jdk   文件: TCKMonthDay.java
@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));
}
 
源代码17 项目: jdk8u-dev-jdk   文件: TCKMonthDay.java
@Test
public void test_withMonth() {
    assertEquals(MonthDay.of(6, 30).withMonth(1), MonthDay.of(1, 30));
}
 
源代码18 项目: hottub   文件: TCKMonthDay.java
@Test
public void test_withMonth_int_noChangeEqual() {
    MonthDay test = MonthDay.of(6, 30);
    assertEquals(test.withMonth(6), test);
}
 
源代码19 项目: jdk8u_jdk   文件: TCKMonthDay.java
@Test
public void factory_intMonth() {
    assertEquals(TEST_07_15, MonthDay.of(Month.JULY, 15));
}
 
源代码20 项目: openjdk-8-source   文件: TCKMonthDay.java
@Test
public void test_atYear_int() {
    MonthDay test = MonthDay.of(6, 30);
    assertEquals(test.atYear(2008), LocalDate.of(2008, 6, 30));
}
 
源代码21 项目: jdk8u-jdk   文件: TCKMonthDay.java
@Test(expectedExceptions=NullPointerException.class)
public void factory_parse_formatter_nullFormatter() {
    MonthDay.parse("ANY", null);
}
 
源代码22 项目: TencentKona-8   文件: TCKMonthDay.java
@Test(expectedExceptions=DateTimeException.class)
public void test_withMonth_tooLow() {
    MonthDay.of(6, 30).withMonth(0);
}
 
源代码23 项目: jdk8u-jdk   文件: TCKMonthDay.java
@Test
public void test_with_Month_adjustToValid() {
    assertEquals(MonthDay.of(7, 31).with(Month.JUNE), MonthDay.of(6, 30));
}
 
源代码24 项目: TencentKona-8   文件: TCKMonthDay.java
@Test(expectedExceptions=NullPointerException.class)
public void factory_parse_formatter_nullText() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("M d");
    MonthDay.parse((String) null, f);
}
 
源代码25 项目: jdk8u-jdk   文件: TestMonthDay.java
@Test
public void test_withMonth_int_noChangeSame() {
    MonthDay test = MonthDay.of(6, 30);
    assertSame(test.withMonth(6), test);
}
 
源代码26 项目: hottub   文件: TCKYear.java
@Test(dataProvider="atMonthDay")
public void test_atMonthDay(Year year, MonthDay monthDay, LocalDate expected) {
    assertEquals(year.atMonthDay(monthDay), expected);
}
 
源代码27 项目: j2objc   文件: TCKMonthDay.java
@Test
public void test_with_Month_adjustToValid() {
    assertEquals(MonthDay.of(7, 31).with(Month.JUNE), MonthDay.of(6, 30));
}
 
源代码28 项目: jdk8u60   文件: TCKYear.java
@Test(dataProvider="isValidMonthDay")
public void test_isValidMonthDay(Year year, MonthDay monthDay, boolean expected) {
    assertEquals(year.isValidMonthDay(monthDay), expected);
}
 
源代码29 项目: openjdk-8-source   文件: TCKMonthDay.java
@Test(expectedExceptions=DateTimeException.class)
public void test_factory_ints_dayTooHigh() {
    MonthDay.of(1, 32);
}
 
源代码30 项目: jdk8u60   文件: TCKMonthDay.java
@Test(dataProvider="goodParseData")
public void factory_parse_success(String text, MonthDay expected) {
    MonthDay monthDay = MonthDay.parse(text);
    assertEquals(monthDay, expected);
}
 
 类所在包
 同包方法