use of java.time.temporal.TemporalAccessor in project jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatters method test_print_rfc1123_missingField.
@Test(expectedExceptions = DateTimeException.class)
public void test_print_rfc1123_missingField() {
TemporalAccessor test = YearMonth.of(2008, 6);
DateTimeFormatter.RFC_1123_DATE_TIME.format(test);
}
use of java.time.temporal.TemporalAccessor in project jdk8u_jdk by JetBrains.
the class TCKDateTimeParseResolver method test_parse_fromField_SecondOfDay.
// SPEC: ChronoField.SECOND_OF_DAY
@Test
public void test_parse_fromField_SecondOfDay() {
DateTimeFormatter fmt = new DateTimeFormatterBuilder().appendValue(SECOND_OF_DAY).toFormatter();
TemporalAccessor acc = fmt.parse("864");
assertEquals(acc.isSupported(SECOND_OF_DAY), true);
assertEquals(acc.isSupported(NANO_OF_SECOND), true);
assertEquals(acc.isSupported(MICRO_OF_SECOND), true);
assertEquals(acc.isSupported(MILLI_OF_SECOND), true);
assertEquals(acc.getLong(SECOND_OF_DAY), 864L);
assertEquals(acc.getLong(NANO_OF_SECOND), 0L);
assertEquals(acc.getLong(MICRO_OF_SECOND), 0L);
assertEquals(acc.getLong(MILLI_OF_SECOND), 0L);
}
use of java.time.temporal.TemporalAccessor in project jdk8u_jdk by JetBrains.
the class TCKDateTimeParseResolver method test_withChronology_parsedChronology_override.
@Test
public void test_withChronology_parsedChronology_override() {
DateTimeFormatter f = new DateTimeFormatterBuilder().parseDefaulting(EPOCH_DAY, 2).appendChronologyId().toFormatter();
f = f.withChronology(MinguoChronology.INSTANCE);
TemporalAccessor accessor = f.parse("ThaiBuddhist");
assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(1970, 1, 3));
assertEquals(accessor.query(TemporalQueries.localTime()), null);
assertEquals(accessor.query(TemporalQueries.chronology()), ThaiBuddhistChronology.INSTANCE);
}
use of java.time.temporal.TemporalAccessor in project jdk8u_jdk by JetBrains.
the class TCKDateTimeParseResolver method test_resolveOneToTime.
@Test(dataProvider = "resolveOneToTime")
public void test_resolveOneToTime(TemporalField field1, long value1, LocalTime expectedTime) {
String str = Long.toString(value1);
DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field1).toFormatter();
TemporalAccessor accessor = f.parse(str);
assertEquals(accessor.query(TemporalQueries.localDate()), null);
assertEquals(accessor.query(TemporalQueries.localTime()), expectedTime);
}
use of java.time.temporal.TemporalAccessor in project jdk8u_jdk by JetBrains.
the class TCKDateTimeParseResolver method test_fieldResolvesToChronoLocalDateTime_noOverrideChrono_matches.
//-------------------------------------------------------------------------
@Test
public void test_fieldResolvesToChronoLocalDateTime_noOverrideChrono_matches() {
LocalDateTime ldt = LocalDateTime.of(2010, 6, 30, 12, 30);
DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(ldt)).toFormatter();
TemporalAccessor accessor = f.parse("1234567890");
assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(2010, 6, 30));
assertEquals(accessor.query(TemporalQueries.localTime()), LocalTime.of(12, 30));
assertEquals(accessor.query(TemporalQueries.chronology()), IsoChronology.INSTANCE);
}
Aggregations