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

The following examples show how to use java.time.Year#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: TCKYear.java    From jdk8u-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 {
        Year.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: TCKYear.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void factory_parse_formatter() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("y");
    Year test = Year.parse("2010", f);
    assertEquals(test, Year.of(2010));
}
 
Example 3
Source File: TCKYear.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="goodParseData")
public void factory_parse_success(String text, Year expected) {
    Year year = Year.parse(text);
    assertEquals(year, expected);
}
 
Example 4
Source File: TCKYear.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void factory_parse_formatter() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("y");
    Year test = Year.parse("2010", f);
    assertEquals(test, Year.of(2010));
}
 
Example 5
Source File: TCKYear.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void factory_parse_formatter_nullFormatter() {
    Year.parse("ANY", null);
}
 
Example 6
Source File: TCKYear.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void factory_parse_formatter_nullFormatter() {
    Year.parse("ANY", null);
}
 
Example 7
Source File: TCKYear.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="goodParseData")
public void factory_parse_success(String text, Year expected) {
    Year year = Year.parse(text);
    assertEquals(year, expected);
}
 
Example 8
Source File: TCKYear.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void factory_parse_formatter() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("y");
    Year test = Year.parse("2010", f);
    assertEquals(test, Year.of(2010));
}
 
Example 9
Source File: TCKYear.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void factory_parse_formatter() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("y");
    Year test = Year.parse("2010", f);
    assertEquals(test, Year.of(2010));
}
 
Example 10
Source File: TCKYear.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_nullText() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("y");
    Year.parse((String) null, f);
}
 
Example 11
Source File: TCKYear.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void factory_parse_formatter() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("y");
    Year test = Year.parse("2010", f);
    assertEquals(test, Year.of(2010));
}
 
Example 12
Source File: TCKYear.java    From j2objc with Apache License 2.0 4 votes vote down vote up
@Test
public void factory_parse_formatter() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("y");
    Year test = Year.parse("2010", f);
    assertEquals(test, Year.of(2010));
}
 
Example 13
Source File: TCKYear.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_nullText() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("y");
    Year.parse((String) null, f);
}
 
Example 14
Source File: TCKYear.java    From openjdk-jdk9 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("y");
    Year.parse((String) null, f);
}
 
Example 15
Source File: TCKYear.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void factory_parse_formatter_nullFormatter() {
    Year.parse("ANY", null);
}
 
Example 16
Source File: TCKYear.java    From hottub 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("y");
    Year.parse((String) null, f);
}
 
Example 17
Source File: TCKYear.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void factory_parse_formatter() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("y");
    Year test = Year.parse("2010", f);
    assertEquals(test, Year.of(2010));
}
 
Example 18
Source File: TCKYear.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_nullFormatter() {
    Year.parse("ANY", null);
}
 
Example 19
Source File: TCKYear.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_nullText() {
    Year.parse(null);
}
 
Example 20
Source File: TCKYear.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void factory_parse_nullText() {
    Year.parse(null);
}