use of java.time.format.DateTimeFormatter in project jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatters method test_pattern_StringLocale.
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
@Test
public void test_pattern_StringLocale() {
DateTimeFormatter test = DateTimeFormatter.ofPattern("d MMM yyyy", Locale.UK);
assertEquals(test.format(LocalDate.of(2012, 6, 30)), "30 Jun 2012");
assertEquals(test.getLocale(), Locale.UK);
}
use of java.time.format.DateTimeFormatter in project jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatter method test_print_TemporalAppendable_nullTemporal.
@Test(expectedExceptions = NullPointerException.class)
public void test_print_TemporalAppendable_nullTemporal() throws Exception {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
StringBuilder buf = new StringBuilder();
test.formatTo((TemporalAccessor) null, buf);
}
use of java.time.format.DateTimeFormatter in project jdk8u_jdk by JetBrains.
the class TestTextPrinter method test_formatDayOfWeek.
@Test(dataProvider = "print_DayOfWeekData")
public void test_formatDayOfWeek(Locale locale, String pattern, String expected, DayOfWeek dayOfWeek) {
DateTimeFormatter formatter = getPatternFormatter(pattern).withLocale(locale);
String text = formatter.format(dayOfWeek);
assertEquals(text, expected);
}
use of java.time.format.DateTimeFormatter in project jdk8u_jdk by JetBrains.
the class TestZoneTextPrinterParser method test_ParseText.
@Test(dataProvider = "preferredZones")
public void test_ParseText(String expected, String text, Set<ZoneId> preferred, Locale locale, TextStyle style) {
DateTimeFormatter fmt = new DateTimeFormatterBuilder().appendZoneText(style, preferred).toFormatter(locale).withDecimalStyle(DecimalStyle.of(locale));
String ret = fmt.parse(text, TemporalQueries.zone()).getId();
System.out.printf("[%-5s %s] %24s -> %s(%s)%n", locale.toString(), style == TextStyle.FULL ? " full" : "short", text, ret, expected);
assertEquals(ret, expected);
}
use of java.time.format.DateTimeFormatter in project jdk8u_jdk by JetBrains.
the class TestZoneTextPrinterParser method parseText.
private void parseText(Set<String> zids, Locale locale, TextStyle style, boolean ci) {
System.out.println("---------------------------------------");
DateTimeFormatter fmt = getFormatter(locale, style, ci);
for (String[] names : new DateFormatSymbols(locale).getZoneStrings()) {
if (!zids.contains(names[0])) {
continue;
}
String zid = names[0];
String expected = ZoneName.toZid(zid, locale);
parse(fmt, zid, expected, zid, locale, style, ci);
int i = style == TextStyle.FULL ? 1 : 2;
for (; i < names.length; i += 2) {
parse(fmt, zid, expected, names[i], locale, style, ci);
}
}
}
Aggregations