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

The following examples show how to use java.time.MonthDay#parse() . 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 jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@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;
    }
}
 
Example 2
Source File: TCKMonthDay.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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;
    }
}
 
Example 3
Source File: TCKMonthDay.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@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;
    }
}
 
Example 4
Source File: TCKMonthDay.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="goodParseData")
public void factory_parse_success(String text, MonthDay expected) {
    MonthDay monthDay = MonthDay.parse(text);
    assertEquals(monthDay, expected);
}
 
Example 5
Source File: TCKMonthDay.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void factory_parse_formatter() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("M d");
    MonthDay test = MonthDay.parse("12 3", f);
    assertEquals(test, MonthDay.of(12, 3));
}
 
Example 6
Source File: TCKMonthDay.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void factory_parse_formatter_nullText() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("M d");
    MonthDay.parse((String) null, f);
}
 
Example 7
Source File: TCKMonthDay.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="goodParseData")
public void factory_parse_success(String text, MonthDay expected) {
    MonthDay monthDay = MonthDay.parse(text);
    assertEquals(monthDay, expected);
}
 
Example 8
Source File: TCKMonthDay.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void factory_parse_nullText() {
    MonthDay.parse(null);
}
 
Example 9
Source File: TCKMonthDay.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeParseException.class)
public void factory_parse_invalidValue_Day() {
    MonthDay.parse("--06-31");
}
 
Example 10
Source File: JavaTimeSerializersV2d0.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Override
public MonthDay parse(final String val) {
    return MonthDay.parse(val);
}
 
Example 11
Source File: TCKMonthDay.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void factory_parse_nullText() {
    MonthDay.parse(null);
}
 
Example 12
Source File: TCKMonthDay.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeParseException.class)
public void factory_parse_invalidValue_Day() {
    MonthDay.parse("--06-31");
}
 
Example 13
Source File: TCKMonthDay.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void factory_parse_formatter_nullText() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("M d");
    MonthDay.parse((String) null, f);
}
 
Example 14
Source File: TCKMonthDay.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeParseException.class)
public void factory_parse_illegalValue_Month() {
    MonthDay.parse("--13-25");
}
 
Example 15
Source File: TCKMonthDay.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeParseException.class)
public void factory_parse_invalidValue_Day() {
    MonthDay.parse("--06-31");
}
 
Example 16
Source File: MonthDayFormatter.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public MonthDay parse(String text, Locale locale) throws ParseException {
	return MonthDay.parse(text);
}
 
Example 17
Source File: TCKMonthDay.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeParseException.class)
public void factory_parse_illegalValue_Month() {
    MonthDay.parse("--13-25");
}
 
Example 18
Source File: TCKMonthDay.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeParseException.class)
public void factory_parse_illegalValue_Day() {
    MonthDay.parse("--06-32");
}
 
Example 19
Source File: TCKMonthDay.java    From j2objc with Apache License 2.0 4 votes vote down vote up
@Test(expected=DateTimeParseException.class)
public void factory_parse_illegalValue_Day() {
    MonthDay.parse("--06-32");
}
 
Example 20
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_parse_formatter_nullFormatter() {
    MonthDay.parse("ANY", null);
}