< prev index next >

test/java/time/tck/java/time/format/TCKDateTimeFormatterBuilder.java

Print this page

        

*** 791,801 **** --- 791,837 ---- public void test_modJulianFieldValues(int y, int m, int d, String expected) throws Exception { DateTimeFormatter df = new DateTimeFormatterBuilder().appendPattern("g").toFormatter(); assertEquals(LocalDate.of(y, m, d).format(df), expected); } + //----------------------------------------------------------------------- + @DataProvider(name="dayOfYearFieldPattern") + Object[][] data_dayOfYearFieldPattern() { + return new Object[][] { + {"D", "1"}, + {"D", "123"}, + {"DD", "12"}, + {"DD", "123"}, + {"DDD", "123"}, + {"DDD", "12345"}, + }; + } + + @Test(dataProvider="dayOfYearFieldPattern") + public void test_dayOfYearFieldPattern(String pattern, String input) throws Exception { + DateTimeFormatter.ofPattern(pattern).parse(input); + } + @DataProvider(name="dayOfYearFieldValues") + Object[][] data_dayOfYearFieldValues() { + return new Object[][] { + {2016, 1, 1, "D", "1"}, + {2016, 1, 31, "D", "31"}, + {2016, 1, 1, "DD", "01"}, + {2016, 1, 31, "DD", "31"}, + {2016, 4, 9, "DD", "100"}, + {2016, 1, 1, "DDD", "001"}, + {2016, 1, 31, "DDD", "031"}, + {2016, 4, 9, "DDD", "100"}, + }; + } + + @Test(dataProvider="dayOfYearFieldValues") + public void test_dayOfYearFieldValues(int y, int m, int d, String pattern, String expected) throws Exception { + DateTimeFormatter df = new DateTimeFormatterBuilder().appendPattern(pattern).toFormatter(); + assertEquals(LocalDate.of(y, m, d).format(df), expected); + } //----------------------------------------------------------------------- @Test public void test_adjacent_strict_firstFixedWidth() throws Exception { // succeeds because both number elements are fixed width DateTimeFormatter f = builder.appendValue(HOUR_OF_DAY, 2).appendValue(MINUTE_OF_HOUR, 2).appendLiteral('9').toFormatter(Locale.UK);
< prev index next >