use of java.time.temporal.TemporalAccessor in project jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatterBuilder method test_adjacent_strict_fractionFollows_0digit.
@Test
public void test_adjacent_strict_fractionFollows_0digit() throws Exception {
// succeeds because hour/min are fixed width
DateTimeFormatter f = builder.appendValue(HOUR_OF_DAY, 2).appendValue(MINUTE_OF_HOUR, 2).appendFraction(NANO_OF_SECOND, 0, 3, false).toFormatter(Locale.UK);
ParsePosition pp = new ParsePosition(0);
TemporalAccessor parsed = f.parseUnresolved("1230", pp);
assertEquals(pp.getErrorIndex(), -1);
assertEquals(pp.getIndex(), 4);
assertEquals(parsed.getLong(HOUR_OF_DAY), 12L);
assertEquals(parsed.getLong(MINUTE_OF_HOUR), 30L);
}
use of java.time.temporal.TemporalAccessor in project jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatterBuilder method test_adjacent_strict_firstVariableWidth_fails.
@Test
public void test_adjacent_strict_firstVariableWidth_fails() throws Exception {
// fails because literal is a number and variable width parse greedily absorbs it
DateTimeFormatter f = builder.appendValue(HOUR_OF_DAY).appendValue(MINUTE_OF_HOUR, 2).appendLiteral('9').toFormatter(Locale.UK);
ParsePosition pp = new ParsePosition(0);
TemporalAccessor parsed = f.parseUnresolved("12309", pp);
assertEquals(pp.getErrorIndex(), 5);
assertEquals(parsed, null);
}
use of java.time.temporal.TemporalAccessor in project jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatter method test_parse_CharSequence.
//-----------------------------------------------------------------------
// parse(CharSequence)
//-----------------------------------------------------------------------
@Test
public void test_parse_CharSequence() {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
TemporalAccessor result = test.parse("ONE30");
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 TCKDateTimeFormatters method test_print_basicIsoDate_offset.
@Test
public void test_print_basicIsoDate_offset() {
TemporalAccessor test = buildAccessor(LocalDateTime.of(2008, 6, 3, 11, 5, 30), "Z", null);
assertEquals(DateTimeFormatter.BASIC_ISO_DATE.format(test), "20080603Z");
}
use of java.time.temporal.TemporalAccessor in project jdk8u_jdk by JetBrains.
the class TestZoneOffsetParser method test_parse_endStringMatch_EmptyUTC.
@Test(dataProvider = "offsets")
public void test_parse_endStringMatch_EmptyUTC(String pattern, String parse, ZoneOffset expected) throws Exception {
ParsePosition pos = new ParsePosition(5);
TemporalAccessor parsed = getFormatter(pattern, "").parseUnresolved("OTHER" + parse, pos);
assertEquals(pos.getIndex(), parse.length() + 5);
assertParsed(parsed, expected);
}
Aggregations