Search in sources :

Example 31 with MinguoDate

use of java.time.chrono.MinguoDate in project jdk8u_jdk by JetBrains.

the class TCKDateTimeParseResolver method test_fieldResolvesToChronoLocalDateTime_overrideChrono_matches.

@Test
public void test_fieldResolvesToChronoLocalDateTime_overrideChrono_matches() {
    MinguoDate mdt = MinguoDate.of(100, 6, 30);
    DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(mdt.atTime(LocalTime.NOON))).toFormatter();
    f = f.withChronology(MinguoChronology.INSTANCE);
    TemporalAccessor accessor = f.parse("1234567890");
    assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.from(mdt));
    assertEquals(accessor.query(TemporalQueries.localTime()), LocalTime.NOON);
    assertEquals(accessor.query(TemporalQueries.chronology()), MinguoChronology.INSTANCE);
}
Also used : MinguoDate(java.time.chrono.MinguoDate) TemporalAccessor(java.time.temporal.TemporalAccessor) DateTimeFormatter(java.time.format.DateTimeFormatter) DateTimeFormatterBuilder(java.time.format.DateTimeFormatterBuilder) Test(org.testng.annotations.Test)

Aggregations

MinguoDate (java.time.chrono.MinguoDate)31 Test (org.testng.annotations.Test)29 TemporalField (java.time.temporal.TemporalField)10 HashMap (java.util.HashMap)10 DateTimeException (java.time.DateTimeException)7 ChronoPeriod (java.time.chrono.ChronoPeriod)5 DateTimeFormatter (java.time.format.DateTimeFormatter)5 DateTimeFormatterBuilder (java.time.format.DateTimeFormatterBuilder)3 TemporalAccessor (java.time.temporal.TemporalAccessor)3 ThaiBuddhistDate (java.time.chrono.ThaiBuddhistDate)2 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1 OffsetDateTime (java.time.OffsetDateTime)1 ZoneOffset (java.time.ZoneOffset)1 ZonedDateTime (java.time.ZonedDateTime)1 ChronoLocalDate (java.time.chrono.ChronoLocalDate)1 ChronoLocalDateTime (java.time.chrono.ChronoLocalDateTime)1 ChronoZonedDateTime (java.time.chrono.ChronoZonedDateTime)1 JapaneseDate (java.time.chrono.JapaneseDate)1