test/java/time/tck/java/time/format/TCKDateTimeTextPrinting.java
Print this page
*** 134,176 ****
{MONTH_OF_YEAR, TextStyle.SHORT, 12, "Dec"},
};
}
@Test(dataProvider="printText", groups={"tck"})
! public void test_appendText2arg_print(TemporalField field, TextStyle style, int value, String expected) throws Exception {
DateTimeFormatter f = builder.appendText(field, style).toFormatter(Locale.ENGLISH);
LocalDateTime dt = LocalDateTime.of(2010, 1, 1, 0, 0);
dt = dt.with(field, value);
! String text = f.print(dt);
assertEquals(text, expected);
}
@Test(dataProvider="printText", groups={"tck"})
! public void test_appendText1arg_print(TemporalField field, TextStyle style, int value, String expected) throws Exception {
if (style == TextStyle.FULL) {
DateTimeFormatter f = builder.appendText(field).toFormatter(Locale.ENGLISH);
LocalDateTime dt = LocalDateTime.of(2010, 1, 1, 0, 0);
dt = dt.with(field, value);
! String text = f.print(dt);
assertEquals(text, expected);
}
}
//-----------------------------------------------------------------------
@Test(groups={"tck"})
public void test_print_appendText2arg_french_long() throws Exception {
DateTimeFormatter f = builder.appendText(MONTH_OF_YEAR, TextStyle.FULL).toFormatter(Locale.FRENCH);
LocalDateTime dt = LocalDateTime.of(2010, 1, 1, 0, 0);
! String text = f.print(dt);
assertEquals(text, "janvier");
}
@Test(groups={"tck"})
public void test_print_appendText2arg_french_short() throws Exception {
DateTimeFormatter f = builder.appendText(MONTH_OF_YEAR, TextStyle.SHORT).toFormatter(Locale.FRENCH);
LocalDateTime dt = LocalDateTime.of(2010, 1, 1, 0, 0);
! String text = f.print(dt);
assertEquals(text, "janv.");
}
//-----------------------------------------------------------------------
@Test(groups={"tck"})
--- 134,176 ----
{MONTH_OF_YEAR, TextStyle.SHORT, 12, "Dec"},
};
}
@Test(dataProvider="printText", groups={"tck"})
! public void test_appendText2arg_format(TemporalField field, TextStyle style, int value, String expected) throws Exception {
DateTimeFormatter f = builder.appendText(field, style).toFormatter(Locale.ENGLISH);
LocalDateTime dt = LocalDateTime.of(2010, 1, 1, 0, 0);
dt = dt.with(field, value);
! String text = f.format(dt);
assertEquals(text, expected);
}
@Test(dataProvider="printText", groups={"tck"})
! public void test_appendText1arg_format(TemporalField field, TextStyle style, int value, String expected) throws Exception {
if (style == TextStyle.FULL) {
DateTimeFormatter f = builder.appendText(field).toFormatter(Locale.ENGLISH);
LocalDateTime dt = LocalDateTime.of(2010, 1, 1, 0, 0);
dt = dt.with(field, value);
! String text = f.format(dt);
assertEquals(text, expected);
}
}
//-----------------------------------------------------------------------
@Test(groups={"tck"})
public void test_print_appendText2arg_french_long() throws Exception {
DateTimeFormatter f = builder.appendText(MONTH_OF_YEAR, TextStyle.FULL).toFormatter(Locale.FRENCH);
LocalDateTime dt = LocalDateTime.of(2010, 1, 1, 0, 0);
! String text = f.format(dt);
assertEquals(text, "janvier");
}
@Test(groups={"tck"})
public void test_print_appendText2arg_french_short() throws Exception {
DateTimeFormatter f = builder.appendText(MONTH_OF_YEAR, TextStyle.SHORT).toFormatter(Locale.FRENCH);
LocalDateTime dt = LocalDateTime.of(2010, 1, 1, 0, 0);
! String text = f.format(dt);
assertEquals(text, "janv.");
}
//-----------------------------------------------------------------------
@Test(groups={"tck"})
*** 190,200 ****
map.put(12L, "DBR");
builder.appendText(MONTH_OF_YEAR, map);
DateTimeFormatter f = builder.toFormatter();
LocalDateTime dt = LocalDateTime.of(2010, 1, 1, 0, 0);
for (Month month : Month.values()) {
! assertEquals(f.print(dt.with(month)), map.get((long) month.getValue()));
}
}
@Test(groups={"tck"})
public void test_appendTextMap_DOM() throws Exception {
--- 190,200 ----
map.put(12L, "DBR");
builder.appendText(MONTH_OF_YEAR, map);
DateTimeFormatter f = builder.toFormatter();
LocalDateTime dt = LocalDateTime.of(2010, 1, 1, 0, 0);
for (Month month : Month.values()) {
! assertEquals(f.format(dt.with(month)), map.get((long) month.getValue()));
}
}
@Test(groups={"tck"})
public void test_appendTextMap_DOM() throws Exception {
*** 203,223 ****
map.put(2L, "2nd");
map.put(3L, "3rd");
builder.appendText(DAY_OF_MONTH, map);
DateTimeFormatter f = builder.toFormatter();
LocalDateTime dt = LocalDateTime.of(2010, 1, 1, 0, 0);
! assertEquals(f.print(dt.withDayOfMonth(1)), "1st");
! assertEquals(f.print(dt.withDayOfMonth(2)), "2nd");
! assertEquals(f.print(dt.withDayOfMonth(3)), "3rd");
}
@Test(groups={"tck"})
public void test_appendTextMapIncomplete() throws Exception {
Map<Long, String> map = new HashMap<Long, String>();
map.put(1L, "JNY");
builder.appendText(MONTH_OF_YEAR, map);
DateTimeFormatter f = builder.toFormatter();
LocalDateTime dt = LocalDateTime.of(2010, 2, 1, 0, 0);
! assertEquals(f.print(dt), "2");
}
}
--- 203,223 ----
map.put(2L, "2nd");
map.put(3L, "3rd");
builder.appendText(DAY_OF_MONTH, map);
DateTimeFormatter f = builder.toFormatter();
LocalDateTime dt = LocalDateTime.of(2010, 1, 1, 0, 0);
! assertEquals(f.format(dt.withDayOfMonth(1)), "1st");
! assertEquals(f.format(dt.withDayOfMonth(2)), "2nd");
! assertEquals(f.format(dt.withDayOfMonth(3)), "3rd");
}
@Test(groups={"tck"})
public void test_appendTextMapIncomplete() throws Exception {
Map<Long, String> map = new HashMap<Long, String>();
map.put(1L, "JNY");
builder.appendText(MONTH_OF_YEAR, map);
DateTimeFormatter f = builder.toFormatter();
LocalDateTime dt = LocalDateTime.of(2010, 2, 1, 0, 0);
! assertEquals(f.format(dt), "2");
}
}