Search in sources :

Example 1 with MinguoDate

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

the class TestReducedPrinter method test_minguoChrono_extendedWidth.

public void test_minguoChrono_extendedWidth() throws Exception {
    // ISO 2021 is Minguo 110
    DateTimeFormatter f = getFormatterBaseDate(YEAR, 2, 4, 2021);
    MinguoDate date = MinguoDate.of(109, 6, 30);
    assertEquals(f.format(date), "109");
    date = MinguoDate.of(110, 6, 30);
    assertEquals(f.format(date), "10");
    date = MinguoDate.of(199, 6, 30);
    assertEquals(f.format(date), "99");
    date = MinguoDate.of(200, 6, 30);
    assertEquals(f.format(date), "00");
    date = MinguoDate.of(209, 6, 30);
    assertEquals(f.format(date), "09");
    date = MinguoDate.of(210, 6, 30);
    assertEquals(f.format(date), "210");
}
Also used : MinguoDate(java.time.chrono.MinguoDate) DateTimeFormatter(java.time.format.DateTimeFormatter)

Example 2 with MinguoDate

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

the class TCKThaiBuddhistChronology method test_periodUntilDiffChrono.

@Test
public void test_periodUntilDiffChrono() {
    ThaiBuddhistDate mdate1 = ThaiBuddhistDate.of(1, 1, 1);
    ThaiBuddhistDate mdate2 = ThaiBuddhistDate.of(2, 2, 2);
    MinguoDate ldate2 = MinguoChronology.INSTANCE.date(mdate2);
    ChronoPeriod period = mdate1.until(ldate2);
    assertEquals(period, ThaiBuddhistChronology.INSTANCE.period(1, 1, 1));
}
Also used : ChronoPeriod(java.time.chrono.ChronoPeriod) ThaiBuddhistDate(java.time.chrono.ThaiBuddhistDate) MinguoDate(java.time.chrono.MinguoDate) Test(org.testng.annotations.Test)

Example 3 with MinguoDate

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

the class TCKDateTimeParseResolver method test_fieldResolvesToChronoZonedDateTime_overrideChrono_matches.

@Test
public void test_fieldResolvesToChronoZonedDateTime_overrideChrono_matches() {
    MinguoDate mdt = MinguoDate.of(100, 6, 30);
    ChronoZonedDateTime<MinguoDate> mzdt = mdt.atTime(LocalTime.NOON).atZone(EUROPE_PARIS);
    DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(mzdt)).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);
    assertEquals(accessor.query(TemporalQueries.zoneId()), EUROPE_PARIS);
}
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)

Example 4 with MinguoDate

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

the class TestUmmAlQuraChronology method test_periodUntilDiffChrono.

// Test to get the Period between dates in different chronologies
@Test(dataProvider = "datesForPeriod")
public void test_periodUntilDiffChrono(HijrahDate h1, HijrahDate h2, ChronoPeriod p) {
    MinguoDate m = MinguoChronology.INSTANCE.date(h2);
    ChronoPeriod period = h1.until(m);
    assertEquals(period, p);
}
Also used : ChronoPeriod(java.time.chrono.ChronoPeriod) MinguoDate(java.time.chrono.MinguoDate) Test(org.testng.annotations.Test)

Example 5 with MinguoDate

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

the class TCKMinguoChronology method test_adjust1.

//-----------------------------------------------------------------------
// with(DateTimeAdjuster)
//-----------------------------------------------------------------------
@Test
public void test_adjust1() {
    MinguoDate base = MinguoChronology.INSTANCE.date(2012, 10, 29);
    MinguoDate test = base.with(TemporalAdjusters.lastDayOfMonth());
    assertEquals(test, MinguoChronology.INSTANCE.date(2012, 10, 31));
}
Also used : MinguoDate(java.time.chrono.MinguoDate) 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