use of java.text.ParsePosition in project jdk8u_jdk by JetBrains.
the class TestTextParser method test_parse_midStr.
//-----------------------------------------------------------------------
public void test_parse_midStr() throws Exception {
ParsePosition pos = new ParsePosition(3);
assertEquals(getFormatter(DAY_OF_WEEK, TextStyle.FULL).parseUnresolved("XxxMondayXxx", pos).getLong(DAY_OF_WEEK), 1L);
assertEquals(pos.getIndex(), 9);
}
use of java.text.ParsePosition 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.text.ParsePosition 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);
}
use of java.text.ParsePosition in project jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatter method test_parse_CharSequence_ParsePosition_nullText.
@Test(expectedExceptions = NullPointerException.class)
public void test_parse_CharSequence_ParsePosition_nullText() {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
test.parse((CharSequence) null, new ParsePosition(0));
}
use of java.text.ParsePosition in project jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatter method test_toFormat_parseObject_StringParsePosition_parseError.
@Test
public void test_toFormat_parseObject_StringParsePosition_parseError() throws Exception {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
Format format = test.toFormat();
ParsePosition pos = new ParsePosition(0);
TemporalAccessor result = (TemporalAccessor) format.parseObject("ONEXXX", pos);
// TODO: is this right?
assertEquals(pos.getIndex(), 0);
assertEquals(pos.getErrorIndex(), 3);
assertEquals(result, null);
}
Aggregations