Java 类java.time.chrono.MinguoChronology 实例源码

项目:openjdk-jdk10    文件:TestReducedParser.java   
@DataProvider(name="ReducedWithChrono")
Object[][] provider_reducedWithChrono() {
    LocalDate baseYear = LocalDate.of(2000, 1, 1);
    return new Object[][] {
        {IsoChronology.INSTANCE.date(baseYear)},
        {IsoChronology.INSTANCE.date(baseYear).plus(1, YEARS)},
        {IsoChronology.INSTANCE.date(baseYear).plus(99, YEARS)},
        {HijrahChronology.INSTANCE.date(baseYear)},
        {HijrahChronology.INSTANCE.date(baseYear).plus(1, YEARS)},
        {HijrahChronology.INSTANCE.date(baseYear).plus(99, YEARS)},
        {JapaneseChronology.INSTANCE.date(baseYear)},
        {JapaneseChronology.INSTANCE.date(baseYear).plus(1, YEARS)},
        {JapaneseChronology.INSTANCE.date(baseYear).plus(99, YEARS)},
        {MinguoChronology.INSTANCE.date(baseYear)},
        {MinguoChronology.INSTANCE.date(baseYear).plus(1, YEARS)},
        {MinguoChronology.INSTANCE.date(baseYear).plus(99, YEARS)},
        {ThaiBuddhistChronology.INSTANCE.date(baseYear)},
        {ThaiBuddhistChronology.INSTANCE.date(baseYear).plus(1, YEARS)},
        {ThaiBuddhistChronology.INSTANCE.date(baseYear).plus(99, YEARS)},
    };
}
项目:jdk8u-jdk    文件:TCKMinguoChronology.java   
@Test
public void test_dateNow(){
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now()) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now(ZoneId.systemDefault())) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now(Clock.systemDefaultZone())) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now(Clock.systemDefaultZone().getZone())) ;

    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoChronology.INSTANCE.dateNow(ZoneId.systemDefault())) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoChronology.INSTANCE.dateNow(Clock.systemDefaultZone())) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoChronology.INSTANCE.dateNow(Clock.systemDefaultZone().getZone())) ;

    ZoneId zoneId = ZoneId.of("Europe/Paris");
    assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoChronology.INSTANCE.dateNow(Clock.system(zoneId))) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoChronology.INSTANCE.dateNow(Clock.system(zoneId).getZone())) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoDate.now(Clock.system(zoneId))) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoDate.now(Clock.system(zoneId).getZone())) ;

    assertEquals(MinguoChronology.INSTANCE.dateNow(ZoneId.of(ZoneOffset.UTC.getId())), MinguoChronology.INSTANCE.dateNow(Clock.systemUTC())) ;
}
项目:jdk8u-jdk    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_yearOfEra")
public void test_resolve_yearOfEra(ResolverStyle style, Integer e, Integer yoe, Integer y, ChronoField field, Integer expected) {
    Map<TemporalField, Long> fieldValues = new HashMap<>();
    if (e != null) {
        fieldValues.put(ChronoField.ERA, (long) e);
    }
    if (yoe != null) {
        fieldValues.put(ChronoField.YEAR_OF_ERA, (long) yoe);
    }
    if (y != null) {
        fieldValues.put(ChronoField.YEAR, (long) y);
    }
    if (field != null) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, style);
        assertEquals(date, null);
        assertEquals(fieldValues.get(field), (Long) expected.longValue());
        assertEquals(fieldValues.size(), 1);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, style);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_ymd")
public void test_resolve_ymd_strict(int y, int m, int d, MinguoDate expected, Object 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.DAY_OF_MONTH, (long) d);
    if (strict) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_smart(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);
    if (smart) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_strict(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);
    if (strict) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_ymaa")
public void test_resolve_ymaa_smart(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);
    if (smart) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_ymaa")
public void test_resolve_ymaa_strict(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);
    if (strict) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件:TestReducedParser.java   
@DataProvider(name="ReducedWithChrono")
Object[][] provider_reducedWithChrono() {
    LocalDate baseYear = LocalDate.of(2000, 1, 1);
    return new Object[][] {
        {IsoChronology.INSTANCE.date(baseYear)},
        {IsoChronology.INSTANCE.date(baseYear).plus(1, YEARS)},
        {IsoChronology.INSTANCE.date(baseYear).plus(99, YEARS)},
        {HijrahChronology.INSTANCE.date(baseYear)},
        {HijrahChronology.INSTANCE.date(baseYear).plus(1, YEARS)},
        {HijrahChronology.INSTANCE.date(baseYear).plus(99, YEARS)},
        {JapaneseChronology.INSTANCE.date(baseYear)},
        {JapaneseChronology.INSTANCE.date(baseYear).plus(1, YEARS)},
        {JapaneseChronology.INSTANCE.date(baseYear).plus(99, YEARS)},
        {MinguoChronology.INSTANCE.date(baseYear)},
        {MinguoChronology.INSTANCE.date(baseYear).plus(1, YEARS)},
        {MinguoChronology.INSTANCE.date(baseYear).plus(99, YEARS)},
        {ThaiBuddhistChronology.INSTANCE.date(baseYear)},
        {ThaiBuddhistChronology.INSTANCE.date(baseYear).plus(1, YEARS)},
        {ThaiBuddhistChronology.INSTANCE.date(baseYear).plus(99, YEARS)},
    };
}
项目:openjdk-jdk10    文件:TCKChronology.java   
@DataProvider(name = "epochSecond_dataProvider")
Object[][]  data_epochSecond() {
    return new Object[][] {
            {JapaneseChronology.INSTANCE, 1873, 9, 7, 1, 2, 2, OFFSET_P0100},
            {JapaneseChronology.INSTANCE, 1928, 2, 28, 1, 2, 2, OFFSET_M0100},
            {JapaneseChronology.INSTANCE, 1989, 1, 8, 1, 2, 2, OFFSET_P0100},
            {HijrahChronology.INSTANCE, 1434, 9, 7, 1, 2, 2, OFFSET_P0100},
            {MinguoChronology.INSTANCE, 1873, 9, 7, 1, 2, 2, OFFSET_P0100},
            {MinguoChronology.INSTANCE, 1928, 2, 28, 1, 2, 2, OFFSET_M0100},
            {MinguoChronology.INSTANCE, 1989, 1, 8, 1, 2, 2, OFFSET_P0100},
            {ThaiBuddhistChronology.INSTANCE, 1873, 9, 7, 1, 2, 2, OFFSET_P0100},
            {ThaiBuddhistChronology.INSTANCE, 1928, 2, 28, 1, 2, 2, OFFSET_M0100},
            {ThaiBuddhistChronology.INSTANCE, 1989, 1, 8, 1, 2, 2, OFFSET_P0100},
            {IsoChronology.INSTANCE, 1873, 9, 7, 1, 2, 2, OFFSET_P0100},
            {IsoChronology.INSTANCE, 1928, 2, 28, 1, 2, 2, OFFSET_M0100},
            {IsoChronology.INSTANCE, 1989, 1, 8, 1, 2, 2, OFFSET_P0100},

    };
}
项目:openjdk-jdk10    文件:TCKChronology.java   
@DataProvider(name = "era_epochSecond_dataProvider")
Object[][]  data_era_epochSecond() {
    return new Object[][] {
            {JapaneseChronology.INSTANCE, JapaneseEra.MEIJI, 1873 - YDIFF_MEIJI, 9, 7, 1, 2, 2, OFFSET_P0100},
            {JapaneseChronology.INSTANCE, JapaneseEra.SHOWA, 1928 - YDIFF_SHOWA, 2, 28, 1, 2, 2, OFFSET_M0100},
            {JapaneseChronology.INSTANCE, JapaneseEra.HEISEI, 1989 - YDIFF_HEISEI, 1, 8, 1, 2, 2, OFFSET_P0100},
            {HijrahChronology.INSTANCE, HijrahEra.AH, 1434, 9, 7, 1, 2, 2, OFFSET_P0100},
            {MinguoChronology.INSTANCE, MinguoEra.BEFORE_ROC, 1873 - YDIFF_MINGUO, 9, 7, 1, 2, 2, OFFSET_P0100},
            {MinguoChronology.INSTANCE, MinguoEra.ROC, 1928 - YDIFF_MINGUO, 2, 28, 1, 2, 2, OFFSET_M0100},
            {MinguoChronology.INSTANCE, MinguoEra.ROC, 1989 - YDIFF_MINGUO, 1, 8, 1, 2, 2, OFFSET_P0100},
            {ThaiBuddhistChronology.INSTANCE, ThaiBuddhistEra.BE, 1873 + YDIFF_THAIBUDDHIST, 9, 7, 1, 2, 2, OFFSET_P0100},
            {ThaiBuddhistChronology.INSTANCE, ThaiBuddhistEra.BE, 1928 + YDIFF_THAIBUDDHIST, 2, 28, 1, 2, 2, OFFSET_M0100},
            {ThaiBuddhistChronology.INSTANCE, ThaiBuddhistEra.BE, 1989 + YDIFF_THAIBUDDHIST, 1, 8, 1, 2, 2, OFFSET_P0100},
            {IsoChronology.INSTANCE, IsoEra.CE, 1873, 9, 7, 1, 2, 2, OFFSET_P0100},
            {IsoChronology.INSTANCE, IsoEra.CE, 1928, 2, 28, 1, 2, 2, OFFSET_M0100},
            {IsoChronology.INSTANCE, IsoEra.CE, 1989, 1, 8, 1, 2, 2, OFFSET_P0100},

    };
}
项目:openjdk-jdk10    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_ymaa")
public void test_resolve_ymaa_strict(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);
    if (strict) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:openjdk-jdk10    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_ymaa")
public void test_resolve_ymaa_smart(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);
    if (smart) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:openjdk-jdk10    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_ymd")
public void test_resolve_ymd_strict(int y, int m, int d, MinguoDate expected, Object 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.DAY_OF_MONTH, (long) d);
    if (strict) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:openjdk-jdk10    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_smart(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);
    if (smart) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:openjdk-jdk10    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_strict(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);
    if (strict) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件:TCKDateTimeParseResolver.java   
@Test
public void test_withChronology_override() {
    DateTimeFormatter f = new DateTimeFormatterBuilder().parseDefaulting(EPOCH_DAY, 2).toFormatter();
    f = f.withChronology(MinguoChronology.INSTANCE);
    TemporalAccessor accessor = f.parse("");
    assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(1970, 1, 3));
    assertEquals(accessor.query(TemporalQueries.localTime()), null);
    assertEquals(accessor.query(TemporalQueries.chronology()), MinguoChronology.INSTANCE);
}
项目:jdk8u-jdk    文件:TCKDateTimeParseResolver.java   
@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);
}
项目:jdk8u-jdk    文件:TCKDateTimeParseResolver.java   
@Test
public void test_fieldResolvesToChronoLocalDate_overrideChrono_matches() {
    MinguoDate mdt = MinguoDate.of(100, 6, 30);
    DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(mdt)).toFormatter();
    f = f.withChronology(MinguoChronology.INSTANCE);
    TemporalAccessor accessor = f.parse("1234567890");
    assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.from(mdt));
    assertEquals(accessor.query(TemporalQueries.localTime()), null);
    assertEquals(accessor.query(TemporalQueries.chronology()), MinguoChronology.INSTANCE);
}
项目:openjdk-jdk10    文件:TCKChronoLocalDateTimeSerialization.java   
@DataProvider(name = "calendars")
Chronology[][] data_of_calendars() {
    return new Chronology[][]{
                {HijrahChronology.INSTANCE},
                {IsoChronology.INSTANCE},
                {JapaneseChronology.INSTANCE},
                {MinguoChronology.INSTANCE},
                {ThaiBuddhistChronology.INSTANCE}};
}
项目:jdk8u-jdk    文件:TCKDateTimeParseResolver.java   
@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);
}
项目:jdk8u-jdk    文件:TCKDateTimeParseResolver.java   
@Test(expectedExceptions = DateTimeParseException.class)
public void test_fieldResolvesToChronoLocalDateTime_overrideChrono_wrongChrono() {
    ChronoLocalDateTime<?> cldt = ThaiBuddhistChronology.INSTANCE.dateNow().atTime(LocalTime.NOON);
    DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(cldt)).toFormatter();
    f = f.withChronology(MinguoChronology.INSTANCE);
    f.parse("1234567890");
}
项目:jdk8u-jdk    文件:TCKDateTimeParseResolver.java   
@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);
}
项目:jdk8u-jdk    文件:TCKDateTimeParseResolver.java   
@Test(expectedExceptions = DateTimeParseException.class)
public void test_fieldResolvesToChronoZonedDateTime_overrideChrono_wrongChrono() {
    ChronoZonedDateTime<?> cldt = ThaiBuddhistChronology.INSTANCE.dateNow().atTime(LocalTime.NOON).atZone(EUROPE_PARIS);
    DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(cldt)).toFormatter();
    f = f.withChronology(MinguoChronology.INSTANCE);
    f.parse("1234567890");
}
项目:jdk8u-jdk    文件:TCKChronology.java   
@DataProvider(name = "calendarsystemtype")
Object[][] data_CalendarType() {
    return new Object[][] {
        {HijrahChronology.INSTANCE, "islamic-umalqura"},
        {IsoChronology.INSTANCE, "iso8601"},
        {JapaneseChronology.INSTANCE, "japanese"},
        {MinguoChronology.INSTANCE, "roc"},
        {ThaiBuddhistChronology.INSTANCE, "buddhist"},
    };
}
项目:jdk8u-jdk    文件:TCKChronology.java   
@Test
public void test_MinguoChronology_dateNow() {
    ZoneId zoneId_paris = ZoneId.of("Europe/Paris");
    Clock clock = Clock.system(zoneId_paris);

    Chronology chrono = Chronology.of("Minguo");
    assertEquals(chrono.dateNow(), MinguoChronology.INSTANCE.dateNow());
    assertEquals(chrono.dateNow(zoneId_paris), MinguoChronology.INSTANCE.dateNow(zoneId_paris));
    assertEquals(chrono.dateNow(clock), MinguoChronology.INSTANCE.dateNow(clock));
}
项目:jdk8u-jdk    文件:TCKChronology.java   
@Test
public void test_MinguoChronology_dateYearDay() {
    Chronology chrono = Chronology.of("Minguo");
    ChronoLocalDate date1 = chrono.dateYearDay(MinguoEra.ROC, 5, 60);
    ChronoLocalDate date2 = chrono.date(MinguoEra.ROC, 5, 2, 29);
    assertEquals(date1, MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 5, 60));
    assertEquals(date2, MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 5, 60));
}
项目:jdk8u-jdk    文件:TCKChronoPeriod.java   
@DataProvider(name = "calendars")
Chronology[][] data_of_calendars() {
    return new Chronology[][]{
                {HijrahChronology.INSTANCE},
                {IsoChronology.INSTANCE},
                {JapaneseChronology.INSTANCE},
                {MinguoChronology.INSTANCE},
                {ThaiBuddhistChronology.INSTANCE}};
}
项目:jdk8u-jdk    文件:TCKJapaneseChronology.java   
@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));
}
项目:jdk8u-jdk    文件:TCKMinguoChronology.java   
@Test
public void test_chrono_byName() {
    Chronology c = MinguoChronology.INSTANCE;
    Chronology test = Chronology.of("Minguo");
    Assert.assertNotNull(test, "The Minguo calendar could not be found byName");
    Assert.assertEquals(test.getId(), "Minguo", "ID mismatch");
    Assert.assertEquals(test.getCalendarType(), "roc", "Type mismatch");
    Assert.assertEquals(test, c);
}
项目:jdk8u-jdk    文件:TCKMinguoChronology.java   
@DataProvider(name="samples")
Object[][] data_samples() {
    return new Object[][] {
        {MinguoChronology.INSTANCE.date(1, 1, 1), LocalDate.of(1 + YDIFF, 1, 1)},
        {MinguoChronology.INSTANCE.date(1, 1, 2), LocalDate.of(1 + YDIFF, 1, 2)},
        {MinguoChronology.INSTANCE.date(1, 1, 3), LocalDate.of(1 + YDIFF, 1, 3)},

        {MinguoChronology.INSTANCE.date(2, 1, 1), LocalDate.of(2 + YDIFF, 1, 1)},
        {MinguoChronology.INSTANCE.date(3, 1, 1), LocalDate.of(3 + YDIFF, 1, 1)},
        {MinguoChronology.INSTANCE.date(3, 12, 6), LocalDate.of(3 + YDIFF, 12, 6)},
        {MinguoChronology.INSTANCE.date(4, 1, 1), LocalDate.of(4 + YDIFF, 1, 1)},
        {MinguoChronology.INSTANCE.date(4, 7, 3), LocalDate.of(4 + YDIFF, 7, 3)},
        {MinguoChronology.INSTANCE.date(4, 7, 4), LocalDate.of(4 + YDIFF, 7, 4)},
        {MinguoChronology.INSTANCE.date(5, 1, 1), LocalDate.of(5 + YDIFF, 1, 1)},
        {MinguoChronology.INSTANCE.date(100, 3, 3), LocalDate.of(100 + YDIFF, 3, 3)},
        {MinguoChronology.INSTANCE.date(101, 10, 28), LocalDate.of(101 + YDIFF, 10, 28)},
        {MinguoChronology.INSTANCE.date(101, 10, 29), LocalDate.of(101 + YDIFF, 10, 29)},

        {MinguoChronology.INSTANCE.dateYearDay(1916 - YDIFF, 60), LocalDate.of(1916, 2, 29)},
        {MinguoChronology.INSTANCE.dateYearDay(1908 - YDIFF, 60), LocalDate.of(1908, 2, 29)},
        {MinguoChronology.INSTANCE.dateYearDay(2000 - YDIFF, 60), LocalDate.of(2000, 2, 29)},
        {MinguoChronology.INSTANCE.dateYearDay(2400 - YDIFF, 60), LocalDate.of(2400, 2, 29)},

        {MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 1916 - YDIFF, 60), LocalDate.of(1916, 2, 29)},
        {MinguoChronology.INSTANCE.dateYearDay(MinguoEra.BEFORE_ROC, 4, 60), LocalDate.of(1908, 2, 29)},
        {MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 2000 - YDIFF, 60), LocalDate.of(2000, 2, 29)},
        {MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 2400 - YDIFF, 60), LocalDate.of(2400, 2, 29)},

        {MinguoChronology.INSTANCE.date(MinguoEra.ROC, 1916 - YDIFF, 2, 29 ), LocalDate.of(1916, 2, 29)},
        {MinguoChronology.INSTANCE.date(MinguoEra.BEFORE_ROC, 4, 2, 29), LocalDate.of(1908, 2, 29)},
        {MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2000 - YDIFF, 2, 29), LocalDate.of(2000, 2, 29)},
        {MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2400 - YDIFF, 2, 29), LocalDate.of(2400, 2, 29)},
    };
}
项目:jdk8u-jdk    文件:TCKMinguoChronology.java   
@Test()
public void test_MinguoChrono() {
    MinguoDate h1 = MinguoChronology.INSTANCE.date(MinguoEra.ROC, 1, 2, 3);
    MinguoDate h2 = h1;
    ChronoLocalDateTime<MinguoDate> h3 = h2.atTime(LocalTime.NOON);
    @SuppressWarnings("unused")
    ChronoZonedDateTime<MinguoDate> h4 = h3.atZone(ZoneOffset.UTC);
}
项目:jdk8u-jdk    文件:TCKMinguoChronology.java   
@Test(dataProvider="prolepticYear")
public void test_prolepticYear(int eraValue, Era  era, int yearOfEra, int expectedProlepticYear, boolean isLeapYear) {
    Era eraObj = MinguoChronology.INSTANCE.eraOf(eraValue);
    assertTrue(MinguoChronology.INSTANCE.eras().contains(eraObj));
    assertEquals(eraObj, era);
    assertEquals(MinguoChronology.INSTANCE.prolepticYear(era, yearOfEra), expectedProlepticYear);
}
项目:jdk8u-jdk    文件:TCKMinguoChronology.java   
@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);
    }
}
项目:openjdk-jdk10    文件:TCKChronologySerialization.java   
@DataProvider(name = "calendars")
Chronology[][] data_of_calendars() {
    return new Chronology[][]{
                {HijrahChronology.INSTANCE},
                {IsoChronology.INSTANCE},
                {JapaneseChronology.INSTANCE},
                {MinguoChronology.INSTANCE},
                {ThaiBuddhistChronology.INSTANCE}};
}
项目:jdk8u-jdk    文件:TCKMinguoChronology.java   
@DataProvider(name="zonedDateTime")
Object[][] data_zonedDateTime() {
    return new Object[][] {
        {ZonedDateTime.of(2012, 2, 29, 2, 7, 1, 1, ZONE_PARIS), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29), LocalTime.of(2, 7, 1, 1), null},
        {OffsetDateTime.of(2012, 2, 29, 2, 7, 1, 1, OFFSET_PTWO), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29), LocalTime.of(2, 7, 1, 1), null},

        {LocalDateTime.of(2012, 2, 29, 2, 7), null, null, DateTimeException.class},
        {JapaneseDate.of(2012, 2, 29), null, null, DateTimeException.class},
        {ThaiBuddhistDate.of(2012 + 543, 2, 29), null, null, DateTimeException.class},
        {LocalDate.of(2012, 2, 29), null, null, DateTimeException.class},
        {LocalTime.of(20, 30, 29, 0), null, null, DateTimeException.class},
    };
}
项目:jdk8u-jdk    文件:TCKMinguoChronology.java   
@Test
public void test_Instant_zonedDateTime() {
    OffsetDateTime offsetDateTime = OffsetDateTime.of(2012, 2, 29, 2, 7, 1, 1, OFFSET_PTWO);
    ZonedDateTime zonedDateTime = ZonedDateTime.of(2012, 2, 29, 2, 7, 1, 1, ZONE_PARIS);

    ChronoZonedDateTime<MinguoDate> result = MinguoChronology.INSTANCE.zonedDateTime(offsetDateTime.toInstant(), offsetDateTime.getOffset());
    assertEquals(result.toLocalDate(), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29));
    assertEquals(result.toLocalTime(), LocalTime.of(2, 7, 1, 1));

    result = MinguoChronology.INSTANCE.zonedDateTime(zonedDateTime.toInstant(), zonedDateTime.getOffset());
    assertEquals(result.toLocalDate(), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29));
    assertEquals(result.toLocalTime(), LocalTime.of(2, 7, 1, 1));
}
项目:jdk8u-jdk    文件:TCKMinguoChronology.java   
@Test
public void test_periodUntilDate() {
    MinguoDate mdate1 = MinguoDate.of(1970, 1, 1);
    MinguoDate mdate2 = MinguoDate.of(1971, 2, 2);
    ChronoPeriod period = mdate1.until(mdate2);
    assertEquals(period, MinguoChronology.INSTANCE.period(1, 1, 1));
}
项目:jdk8u-jdk    文件:TCKMinguoChronology.java   
@Test
public void test_periodUntilDiffChrono() {
    MinguoDate mdate1 = MinguoDate.of(1970, 1, 1);
    MinguoDate mdate2 = MinguoDate.of(1971, 2, 2);
    ThaiBuddhistDate ldate2 = ThaiBuddhistChronology.INSTANCE.date(mdate2);
    ChronoPeriod period = mdate1.until(ldate2);
    assertEquals(period, MinguoChronology.INSTANCE.period(1, 1, 1));
}
项目:jdk8u-jdk    文件:TCKMinguoChronology.java   
@DataProvider(name="toString")
Object[][] data_toString() {
    return new Object[][] {
        {MinguoChronology.INSTANCE.date(1, 1, 1), "Minguo ROC 1-01-01"},
        {MinguoChronology.INSTANCE.date(1728, 10, 28), "Minguo ROC 1728-10-28"},
        {MinguoChronology.INSTANCE.date(1728, 10, 29), "Minguo ROC 1728-10-29"},
        {MinguoChronology.INSTANCE.date(1727, 12, 5), "Minguo ROC 1727-12-05"},
        {MinguoChronology.INSTANCE.date(1727, 12, 6), "Minguo ROC 1727-12-06"},
    };
}