Search in sources :

Example 26 with MinguoDate

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

the class TCKMinguoChronology method test_resolve_ymaa_lenient.

@Test(dataProvider = "resolve_ymaa")
public void test_resolve_ymaa_lenient(int y, int m, int w, int d, MinguoDate expected, boolean smart, boolean strict) {
    Map<TemporalField, Long> fieldValues = new HashMap<>();
    fieldValues.put(ChronoField.YEAR, (long) y);
    fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m);
    fieldValues.put(ChronoField.ALIGNED_WEEK_OF_MONTH, (long) w);
    fieldValues.put(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH, (long) d);
    MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.LENIENT);
    assertEquals(date, expected);
    assertEquals(fieldValues.size(), 0);
}
Also used : MinguoDate(java.time.chrono.MinguoDate) TemporalField(java.time.temporal.TemporalField) HashMap(java.util.HashMap) Test(org.testng.annotations.Test)

Example 27 with MinguoDate

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

the class TCKMinguoChronology method test_isLeapYear.

@Test(dataProvider = "prolepticYear")
public void test_isLeapYear(int eraValue, Era era, int yearOfEra, int expectedProlepticYear, boolean isLeapYear) {
    assertEquals(MinguoChronology.INSTANCE.isLeapYear(expectedProlepticYear), isLeapYear);
    assertEquals(MinguoChronology.INSTANCE.isLeapYear(expectedProlepticYear), Year.of(expectedProlepticYear + YDIFF).isLeap());
    MinguoDate minguo = MinguoDate.now();
    minguo = minguo.with(ChronoField.YEAR, expectedProlepticYear).with(ChronoField.MONTH_OF_YEAR, 2);
    if (isLeapYear) {
        assertEquals(minguo.lengthOfMonth(), 29);
    } else {
        assertEquals(minguo.lengthOfMonth(), 28);
    }
}
Also used : MinguoDate(java.time.chrono.MinguoDate) Test(org.testng.annotations.Test)

Example 28 with MinguoDate

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

the class TCKMinguoChronology method test_resolve_yd_lenient.

@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_lenient(int y, int d, MinguoDate expected, boolean smart, boolean strict) {
    Map<TemporalField, Long> fieldValues = new HashMap<>();
    fieldValues.put(ChronoField.YEAR, (long) y);
    fieldValues.put(ChronoField.DAY_OF_YEAR, (long) d);
    MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.LENIENT);
    assertEquals(date, expected);
    assertEquals(fieldValues.size(), 0);
}
Also used : MinguoDate(java.time.chrono.MinguoDate) TemporalField(java.time.temporal.TemporalField) HashMap(java.util.HashMap) Test(org.testng.annotations.Test)

Example 29 with MinguoDate

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

the class TCKMinguoChronology method test_adjust_toMonth.

@Test(expectedExceptions = DateTimeException.class)
public void test_adjust_toMonth() {
    MinguoDate minguo = MinguoChronology.INSTANCE.date(1726, 1, 4);
    minguo.with(Month.APRIL);
}
Also used : MinguoDate(java.time.chrono.MinguoDate) Test(org.testng.annotations.Test)

Example 30 with MinguoDate

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

the class TCKJapaneseChronology method test_periodUntilDiffChrono.

@Test
public void test_periodUntilDiffChrono() {
    JapaneseDate mdate1 = JapaneseDate.of(1970, 1, 1);
    JapaneseDate mdate2 = JapaneseDate.of(1971, 2, 2);
    MinguoDate ldate2 = MinguoChronology.INSTANCE.date(mdate2);
    ChronoPeriod period = mdate1.until(ldate2);
    assertEquals(period, JapaneseChronology.INSTANCE.period(1, 1, 1));
}
Also used : ChronoPeriod(java.time.chrono.ChronoPeriod) MinguoDate(java.time.chrono.MinguoDate) JapaneseDate(java.time.chrono.JapaneseDate) 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