use of java.time.temporal.TemporalAccessor in project jdk8u_jdk by JetBrains.
the class TestZoneOffsetParser method test_parse_caseInsensitiveUTC_unmatchedCase.
public void test_parse_caseInsensitiveUTC_unmatchedCase() throws Exception {
setCaseSensitive(false);
ParsePosition pos = new ParsePosition(0);
TemporalAccessor parsed = getFormatter("+HH:MM:ss", "Z").parseUnresolved("z", pos);
assertEquals(pos.getIndex(), 1);
assertParsed(parsed, ZoneOffset.UTC);
}
use of java.time.temporal.TemporalAccessor in project jdk8u_jdk by JetBrains.
the class TestTextParser method test_parse_noMatch_atEnd.
public void test_parse_noMatch_atEnd() throws Exception {
ParsePosition pos = new ParsePosition(6);
TemporalAccessor parsed = getFormatter(DAY_OF_WEEK, TextStyle.FULL).parseUnresolved("Monday", pos);
assertEquals(pos.getErrorIndex(), 6);
assertEquals(parsed, null);
}
use of java.time.temporal.TemporalAccessor in project jdk8u_jdk by JetBrains.
the class TCKChronoPrinterParser method test_parseValid_caseSensitive.
@Test(dataProvider = "parseValid")
public void test_parseValid_caseSensitive(String text, Chronology expected) {
builder.appendChronologyId();
TemporalAccessor parsed = builder.toFormatter().parseUnresolved(text, pos);
assertEquals(pos.getIndex(), expected.getId().length());
assertEquals(pos.getErrorIndex(), -1);
assertEquals(parsed.query(TemporalQueries.chronology()), expected);
}
use of java.time.temporal.TemporalAccessor in project jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatter method test_parse_CharSequence_ParsePosition.
//-----------------------------------------------------------------------
// parse(CharSequence)
//-----------------------------------------------------------------------
@Test
public void test_parse_CharSequence_ParsePosition() {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
ParsePosition pos = new ParsePosition(3);
TemporalAccessor result = test.parse("XXXONE30XXX", pos);
assertEquals(pos.getIndex(), 8);
assertEquals(pos.getErrorIndex(), -1);
assertEquals(result.isSupported(DAY_OF_MONTH), true);
assertEquals(result.getLong(DAY_OF_MONTH), 30L);
assertEquals(result.isSupported(HOUR_OF_DAY), false);
}
use of java.time.temporal.TemporalAccessor in project jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatter method test_parseUnresolved_StringParsePosition_duplicateFieldSameValue.
@Test
public void test_parseUnresolved_StringParsePosition_duplicateFieldSameValue() {
DateTimeFormatter test = new DateTimeFormatterBuilder().appendValue(MONTH_OF_YEAR).appendLiteral('-').appendValue(MONTH_OF_YEAR).toFormatter();
ParsePosition pos = new ParsePosition(3);
TemporalAccessor result = test.parseUnresolved("XXX6-6", pos);
assertEquals(pos.getIndex(), 6);
assertEquals(pos.getErrorIndex(), -1);
assertEquals(result.getLong(MONTH_OF_YEAR), 6);
}
Aggregations