use of java.time.temporal.TemporalAccessor in project jdk8u_jdk by JetBrains.
the class TCKChronoPrinterParser method test_parseValid_caseSensitive_lowercaseRejected.
@Test(dataProvider = "parseValid")
public void test_parseValid_caseSensitive_lowercaseRejected(String text, Chronology expected) {
builder.appendChronologyId();
TemporalAccessor parsed = builder.toFormatter().parseUnresolved(text.toLowerCase(Locale.ENGLISH), pos);
assertEquals(pos.getIndex(), 0);
assertEquals(pos.getErrorIndex(), 0);
assertEquals(parsed, null);
}
use of java.time.temporal.TemporalAccessor in project jdk8u_jdk by JetBrains.
the class TCKChronoPrinterParser method test_parseValid_caseInsensitive.
@Test(dataProvider = "parseValid")
public void test_parseValid_caseInsensitive(String text, Chronology expected) {
builder.parseCaseInsensitive().appendChronologyId();
TemporalAccessor parsed = builder.toFormatter().parseUnresolved(text.toLowerCase(Locale.ENGLISH), 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_parseBest_firstOption.
//-----------------------------------------------------------------------
@Test
public void test_parseBest_firstOption() throws Exception {
DateTimeFormatter test = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm[XXX]");
TemporalAccessor result = test.parseBest("2011-06-30 12:30+03:00", ZonedDateTime::from, LocalDateTime::from);
LocalDateTime ldt = LocalDateTime.of(2011, 6, 30, 12, 30);
assertEquals(result, ZonedDateTime.of(ldt, ZoneOffset.ofHours(3)));
}
use of java.time.temporal.TemporalAccessor 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);
}
use of java.time.temporal.TemporalAccessor 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);
}
Aggregations