use of java.time.format.DateTimeFormatter in project jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatter method test_parseUnresolved_StringParsePosition_parseError.
@Test
public void test_parseUnresolved_StringParsePosition_parseError() {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
ParsePosition pos = new ParsePosition(0);
TemporalAccessor result = test.parseUnresolved("ONEXXX", pos);
assertEquals(pos.getIndex(), 0);
assertEquals(pos.getErrorIndex(), 3);
assertEquals(result, null);
}
use of java.time.format.DateTimeFormatter in project jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatter method test_resolverFields_listOfOneMatching.
@Test
public void test_resolverFields_listOfOneMatching() throws Exception {
DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(YEAR).toFormatter().withResolverFields(YEAR);
TemporalAccessor parsed = f.parse("2012");
assertEquals(parsed.isSupported(YEAR), true);
}
use of java.time.format.DateTimeFormatter in project jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatter method test_toFormat_parseObject_StringParsePosition_nullString.
@Test(expectedExceptions = NullPointerException.class)
public void test_toFormat_parseObject_StringParsePosition_nullString() throws Exception {
// SimpleDateFormat has this behavior
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
Format format = test.toFormat();
ParsePosition pos = new ParsePosition(0);
format.parseObject((String) null, pos);
}
use of java.time.format.DateTimeFormatter in project jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatter method test_parse_CharSequence_ParsePosition_resolved.
@Test
public void test_parse_CharSequence_ParsePosition_resolved() {
DateTimeFormatter test = DateTimeFormatter.ISO_DATE;
ParsePosition pos = new ParsePosition(3);
TemporalAccessor result = test.parse("XXX2012-06-30XXX", pos);
assertEquals(pos.getIndex(), 13);
assertEquals(pos.getErrorIndex(), -1);
assertEquals(result.isSupported(YEAR), true);
assertEquals(result.isSupported(MONTH_OF_YEAR), true);
assertEquals(result.isSupported(DAY_OF_MONTH), true);
assertEquals(result.isSupported(HOUR_OF_DAY), false);
assertEquals(result.getLong(YEAR), 2012L);
assertEquals(result.getLong(MONTH_OF_YEAR), 6L);
assertEquals(result.getLong(DAY_OF_MONTH), 30L);
assertEquals(result.query(LocalDate::from), LocalDate.of(2012, 6, 30));
}
use of java.time.format.DateTimeFormatter in project jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatter method test_resolverFields_listOfOneNotMatching.
@Test
public void test_resolverFields_listOfOneNotMatching() throws Exception {
DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(YEAR).toFormatter().withResolverFields(MONTH_OF_YEAR);
TemporalAccessor parsed = f.parse("2012");
// not in the list of resolverFields
assertEquals(parsed.isSupported(YEAR), false);
assertEquals(parsed.isSupported(MONTH_OF_YEAR), false);
}
Aggregations