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

项目: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    文件: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    文件:TestUmmAlQuraChronology.java   
@Test
public void Test_UmmAlQuraChronoRange() {
    HijrahChronology chrono = HijrahChronology.INSTANCE;
    ValueRange year = chrono.range(YEAR);
    assertEquals(year.getMinimum(), 1300, "Minimum year");
    assertEquals(year.getLargestMinimum(), 1300, "Largest minimum year");
    assertEquals(year.getMaximum(), 1600, "Largest year");
    assertEquals(year.getSmallestMaximum(), 1600, "Smallest Maximum year");

    ValueRange month = chrono.range(MONTH_OF_YEAR);
    assertEquals(month.getMinimum(), 1, "Minimum month");
    assertEquals(month.getLargestMinimum(), 1, "Largest minimum month");
    assertEquals(month.getMaximum(), 12, "Largest month");
    assertEquals(month.getSmallestMaximum(), 12, "Smallest Maximum month");

    ValueRange day = chrono.range(DAY_OF_MONTH);
    assertEquals(day.getMinimum(), 1, "Minimum day");
    assertEquals(day.getLargestMinimum(), 1, "Largest minimum day");
    assertEquals(day.getMaximum(), 30, "Largest day");
    assertEquals(day.getSmallestMaximum(), 29, "Smallest Maximum day");
}
项目:openjdk-jdk10    文件:TestChronologyPerf.java   
@Test
public void test_chronologyGetAvailablePerf() {
    long start = System.nanoTime();
    Set<Chronology> chronos = Chronology.getAvailableChronologies();
    long end = System.nanoTime();
    Duration d = Duration.of(end - start, ChronoUnit.NANOS);
    System.out.printf(" Cold Duration of Chronology.getAvailableChronologies(): %s%n", d);

    start = System.nanoTime();
    chronos = Chronology.getAvailableChronologies();
    end = System.nanoTime();
    d = Duration.of(end - start, ChronoUnit.NANOS);
    System.out.printf(" Warm Duration of Chronology.getAvailableChronologies(): %s%n", d);

    start = System.nanoTime();
    HijrahChronology.INSTANCE.date(1434, 1, 1);
    end = System.nanoTime();
    d = Duration.of(end - start, ChronoUnit.NANOS);
    System.out.printf(" Warm Duration of HijrahDate.date(1434, 1, 1): %s%n", d);
}
项目:jdk8u-jdk    文件:TestChronologyPerf.java   
@Test
public void test_chronologyGetAvailablePerf() {
    long start = System.nanoTime();
    Set<Chronology> chronos = Chronology.getAvailableChronologies();
    long end = System.nanoTime();
    Duration d = Duration.of(end - start, ChronoUnit.NANOS);
    System.out.printf(" Cold Duration of Chronology.getAvailableChronologies(): %s%n", d);

    start = System.nanoTime();
    chronos = Chronology.getAvailableChronologies();
    end = System.nanoTime();
    d = Duration.of(end - start, ChronoUnit.NANOS);
    System.out.printf(" Warm Duration of Chronology.getAvailableChronologies(): %s%n", d);

    start = System.nanoTime();
    HijrahChronology.INSTANCE.date(1434, 1, 1);
    end = System.nanoTime();
    d = Duration.of(end - start, ChronoUnit.NANOS);
    System.out.printf(" Warm Duration of HijrahDate.date(1434, 1, 1): %s%n", d);
}
项目: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    文件:TCKHijrahChronology.java   
@Test
public void test_dateNow(){
    assertEquals(HijrahChronology.INSTANCE.dateNow(), HijrahDate.now()) ;
    assertEquals(HijrahChronology.INSTANCE.dateNow(), HijrahDate.now(ZoneId.systemDefault())) ;
    assertEquals(HijrahChronology.INSTANCE.dateNow(), HijrahDate.now(Clock.systemDefaultZone())) ;
    assertEquals(HijrahChronology.INSTANCE.dateNow(), HijrahDate.now(Clock.systemDefaultZone().getZone())) ;

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

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

    assertEquals(HijrahChronology.INSTANCE.dateNow(ZoneId.of(ZoneOffset.UTC.getId())), HijrahChronology.INSTANCE.dateNow(Clock.systemUTC())) ;
}
项目:openjdk-jdk10    文件:TestUmmAlQuraChronology.java   
@Test
public void Test_UmmAlQuraChronoRange() {
    HijrahChronology chrono = HijrahChronology.INSTANCE;
    ValueRange year = chrono.range(YEAR);
    assertEquals(year.getMinimum(), 1300, "Minimum year");
    assertEquals(year.getLargestMinimum(), 1300, "Largest minimum year");
    assertEquals(year.getMaximum(), 1600, "Largest year");
    assertEquals(year.getSmallestMaximum(), 1600, "Smallest Maximum year");

    ValueRange month = chrono.range(MONTH_OF_YEAR);
    assertEquals(month.getMinimum(), 1, "Minimum month");
    assertEquals(month.getLargestMinimum(), 1, "Largest minimum month");
    assertEquals(month.getMaximum(), 12, "Largest month");
    assertEquals(month.getSmallestMaximum(), 12, "Smallest Maximum month");

    ValueRange day = chrono.range(DAY_OF_MONTH);
    assertEquals(day.getMinimum(), 1, "Minimum day");
    assertEquals(day.getLargestMinimum(), 1, "Largest minimum day");
    assertEquals(day.getMaximum(), 30, "Largest day");
    assertEquals(day.getSmallestMaximum(), 29, "Smallest Maximum day");
}
项目: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_HijrahChronology_dateYearDay() {
    Chronology chrono = Chronology.of("Hijrah");
    ChronoLocalDate date1 = chrono.dateYearDay(HijrahEra.AH, 1434, 178);
    ChronoLocalDate date2 = chrono.date(HijrahEra.AH, 1434, 7, 1);
    assertEquals(date1, HijrahChronology.INSTANCE.dateYearDay(HijrahEra.AH, 1434, 178));
    assertEquals(date2, HijrahChronology.INSTANCE.dateYearDay(HijrahEra.AH, 1434, 178));
}
项目:openjdk-jdk10    文件:Bug8152817.java   
public static void main(String[] args) throws Exception {
    System.setSecurityManager(new SecurityManager());

    DateFormatSymbols syms = DateFormatSymbols.getInstance(Locale.GERMAN);
    if (!"Oktober".equals(syms.getMonths()[Calendar.OCTOBER])) {
        throw new RuntimeException("Test failed (FormatData)");
    }

    String s = HijrahChronology.INSTANCE.getDisplayName(TextStyle.FULL, Locale.GERMAN);
    if (!s.contains("Islamischer Kalender")) {
        throw new RuntimeException("Test failed (JavaTimeSupplementary)");
    }
}
项目:jdk8u-jdk    文件:TCKHijrahEra.java   
@Test(dataProvider="HijrahEras")
public void test_valueOf(HijrahEra era , String eraName, int eraValue) {
    assertEquals(era.getValue(), eraValue);

    assertEquals(HijrahChronology.INSTANCE.eraOf(eraValue), era);
    assertEquals(HijrahEra.of(eraValue), era);
    assertEquals(HijrahEra.valueOf(eraName), era);
}
项目:jdk8u-jdk    文件:TCKChronoZonedDateTime.java   
@DataProvider(name = "calendars")
Chronology[][] data_of_calendars() {
    return new Chronology[][]{
                {HijrahChronology.INSTANCE},
                {IsoChronology.INSTANCE},
                {JapaneseChronology.INSTANCE},
                {MinguoChronology.INSTANCE},
                {ThaiBuddhistChronology.INSTANCE},
    };
}
项目:jdk8u-jdk    文件:TCKHijrahChronology.java   
@Test
public void test_chrono_byName() {
    Chronology c = HijrahChronology.INSTANCE;
    Chronology test = Chronology.of("Hijrah-umalqura");
    Assert.assertNotNull(test, "The Hijrah-umalqura calendar could not be found by name");
    Assert.assertEquals(test.getId(), "Hijrah-umalqura", "ID mismatch");
    Assert.assertEquals(test.getCalendarType(), "islamic-umalqura", "Type mismatch");
    Assert.assertEquals(test, c);
}
项目:openjdk-jdk10    文件:TestUmmAlQuraChronology.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_RIYADH);

    ChronoZonedDateTime<HijrahDate> result = HijrahChronology.INSTANCE.zonedDateTime(offsetDateTime.toInstant(), offsetDateTime.getOffset());
    assertEquals(result.toLocalDate(), HijrahChronology.INSTANCE.date(1433, 4, 7));
    assertEquals(result.toLocalTime(), LocalTime.of(2, 7, 1, 1));

    result = HijrahChronology.INSTANCE.zonedDateTime(zonedDateTime.toInstant(), zonedDateTime.getOffset());
    assertEquals(result.toLocalDate(), HijrahChronology.INSTANCE.date(1433, 4, 7));
    assertEquals(result.toLocalTime(), LocalTime.of(2, 7, 1, 1));
}
项目:jdk8u-jdk    文件:TCKHijrahChronology.java   
@Test(dataProvider = "resolve_styleByEra")
public void test_resolve_yearOfEra_eraOnly_valid(ResolverStyle style, HijrahEra era) {
    Map<TemporalField, Long> fieldValues = new HashMap<>();
    fieldValues.put(ChronoField.ERA, (long) era.getValue());
    HijrahDate date = HijrahChronology.INSTANCE.resolveDate(fieldValues, style);
    assertEquals(date, null);
    assertEquals(fieldValues.get(ChronoField.ERA), (Long) (long) era.getValue());
    assertEquals(fieldValues.size(), 1);
}
项目:jdk8u-jdk    文件:TCKHijrahChronology.java   
@Test(dataProvider = "resolve_styleByEra")
public void test_resolve_yearOfEra_eraAndYearOfEraOnly_valid(ResolverStyle style, HijrahEra era) {
    Map<TemporalField, Long> fieldValues = new HashMap<>();
    fieldValues.put(ChronoField.ERA, (long) era.getValue());
    fieldValues.put(ChronoField.YEAR_OF_ERA, 1343L);
    HijrahDate date = HijrahChronology.INSTANCE.resolveDate(fieldValues, style);
    assertEquals(date, null);
    assertEquals(fieldValues.get(ChronoField.ERA), null);
    assertEquals(fieldValues.get(ChronoField.YEAR_OF_ERA), null);
    assertEquals(fieldValues.get(ChronoField.YEAR), (Long) 1343L);
    assertEquals(fieldValues.size(), 1);
}
项目:jdk8u-jdk    文件:TCKHijrahChronology.java   
@Test(dataProvider = "resolve_styleByEra")
public void test_resolve_yearOfEra_eraAndYearOnly_valid(ResolverStyle style, HijrahEra era) {
    Map<TemporalField, Long> fieldValues = new HashMap<>();
    fieldValues.put(ChronoField.ERA, (long) era.getValue());
    fieldValues.put(ChronoField.YEAR, 1343L);
    HijrahDate date = HijrahChronology.INSTANCE.resolveDate(fieldValues, style);
    assertEquals(date, null);
    assertEquals(fieldValues.get(ChronoField.ERA), (Long) (long) era.getValue());
    assertEquals(fieldValues.get(ChronoField.YEAR), (Long) 1343L);
    assertEquals(fieldValues.size(), 2);
}
项目:jdk8u-jdk    文件:TCKHijrahChronology.java   
@Test(dataProvider = "resolve_styles")
public void test_resolve_yearOfEra_yearOfEraOnly_valid(ResolverStyle style) {
    Map<TemporalField, Long> fieldValues = new HashMap<>();
    fieldValues.put(ChronoField.YEAR_OF_ERA, 1343L);
    HijrahDate date = HijrahChronology.INSTANCE.resolveDate(fieldValues, style);
    assertEquals(date, null);
    assertEquals(fieldValues.get(ChronoField.YEAR_OF_ERA), (style != ResolverStyle.STRICT) ? null : (Long) 1343L);
    assertEquals(fieldValues.get(ChronoField.YEAR), (style == ResolverStyle.STRICT) ? null : (Long) 1343L);
    assertEquals(fieldValues.size(), 1);
}
项目:jdk8u-jdk    文件:TCKHijrahChronology.java   
@Test(dataProvider = "resolve_styles")
public void test_resolve_yearOfEra_yearOfEraAndYearOnly_valid(ResolverStyle style) {
    Map<TemporalField, Long> fieldValues = new HashMap<>();
    fieldValues.put(ChronoField.YEAR_OF_ERA, 1343L);
    fieldValues.put(ChronoField.YEAR, 1343L);
    HijrahDate date = HijrahChronology.INSTANCE.resolveDate(fieldValues, style);
    assertEquals(date, null);
    assertEquals(fieldValues.get(ChronoField.YEAR_OF_ERA), null);
    assertEquals(fieldValues.get(ChronoField.YEAR), (Long) 1343L);
    assertEquals(fieldValues.size(), 1);
}
项目:jdk8u-jdk    文件:TCKHijrahChronology.java   
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_lenient(int y, int d, HijrahDate 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);
    HijrahDate date = HijrahChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.LENIENT);
    assertEquals(date, expected);
    assertEquals(fieldValues.size(), 0);
}
项目:jdk8u-jdk    文件:TCKChronoZonedDateTimeSerialization.java   
@DataProvider(name = "calendars")
Chronology[][] data_of_calendars() {
    return new Chronology[][]{
                {HijrahChronology.INSTANCE},
                {IsoChronology.INSTANCE},
                {JapaneseChronology.INSTANCE},
                {MinguoChronology.INSTANCE},
                {ThaiBuddhistChronology.INSTANCE},
    };
}
项目:jdk8u-jdk    文件:TCKChronoLocalDateTimeSerialization.java   
@DataProvider(name = "calendars")
Chronology[][] data_of_calendars() {
    return new Chronology[][]{
                {HijrahChronology.INSTANCE},
                {IsoChronology.INSTANCE},
                {JapaneseChronology.INSTANCE},
                {MinguoChronology.INSTANCE},
                {ThaiBuddhistChronology.INSTANCE}};
}
项目:jdk8u-jdk    文件:TCKChronologySerialization.java   
@DataProvider(name = "calendars")
Chronology[][] data_of_calendars() {
    return new Chronology[][]{
                {HijrahChronology.INSTANCE},
                {IsoChronology.INSTANCE},
                {JapaneseChronology.INSTANCE},
                {MinguoChronology.INSTANCE},
                {ThaiBuddhistChronology.INSTANCE}};
}
项目:jdk8u-jdk    文件:TCKChronologySerialization.java   
@DataProvider(name = "invalidSerialformClasses")
Object[][] invalid_serial_classes() {
    return new Object[][]{
        {IsoChronology.class},
        {JapaneseChronology.class},
        {MinguoChronology.class},
        {ThaiBuddhistChronology.class},
        {HijrahChronology.class},
    };
}
项目:jdk8u-jdk    文件:TCKChronoLocalDate.java   
@DataProvider(name = "calendars")
Chronology[][] data_of_calendars() {
    return new Chronology[][]{
                {HijrahChronology.INSTANCE},
                {IsoChronology.INSTANCE},
                {JapaneseChronology.INSTANCE},
                {MinguoChronology.INSTANCE},
                {ThaiBuddhistChronology.INSTANCE}};
}
项目:jdk8u-jdk    文件:TCKChronoLocalDateTime.java   
@DataProvider(name = "calendars")
Chronology[][] data_of_calendars() {
    return new Chronology[][]{
                {HijrahChronology.INSTANCE},
                {IsoChronology.INSTANCE},
                {JapaneseChronology.INSTANCE},
                {MinguoChronology.INSTANCE},
                {ThaiBuddhistChronology.INSTANCE}};
}
项目:jdk8u-jdk    文件:TestExampleCode.java   
void HijrahExample1() {
    HijrahDate hd2 = HijrahChronology.INSTANCE.date(1200, 1, 1);

    ChronoLocalDateTime<HijrahDate> hdt = hd2.atTime(LocalTime.MIDNIGHT);
    ChronoZonedDateTime<HijrahDate> zhdt = hdt.atZone(ZoneId.of("GMT"));
    HijrahDate hd3 = zhdt.toLocalDate();
    ChronoLocalDateTime<HijrahDate> hdt2 = zhdt.toLocalDateTime();
    HijrahDate hd4 = hdt2.toLocalDate();

    HijrahDate hd5 = next(hd2);
}
项目:jdk8u-jdk    文件:TestUmmAlQuraChronology.java   
@Test(dataProvider="dates")
public void Test_UmmAlQuraRanges(HijrahDate date,
                    int minYear, int maxYear,
                    int minMonth, int maxMonth,
                    int minDay, int maxDay, int maxChronoDay) {
    // Check the chronology ranges
    HijrahChronology chrono = date.getChronology();
    ValueRange yearRange = chrono.range(YEAR);
    assertEquals(yearRange.getMinimum(), minYear, "Minimum year for Hijrah chronology");
    assertEquals(yearRange.getLargestMinimum(), minYear, "Largest minimum year for Hijrah chronology");
    assertEquals(yearRange.getMaximum(), maxYear, "Maximum year for Hijrah chronology");
    assertEquals(yearRange.getSmallestMaximum(), maxYear, "Smallest Maximum year for Hijrah chronology");

    ValueRange monthRange = chrono.range(MONTH_OF_YEAR);
    assertEquals(monthRange.getMinimum(), minMonth, "Minimum month for Hijrah chronology");
    assertEquals(monthRange.getMaximum(), maxMonth, "Maximum month for Hijrah chronology");

    ValueRange daysRange = chrono.range(DAY_OF_MONTH);
    assertEquals(daysRange.getMinimum(), minDay, "Minimum day for chronology");
    assertEquals(daysRange.getMaximum(), maxChronoDay, "Maximum day for Hijrah chronology");

    // Check the date ranges
    yearRange = date.range(YEAR);
    assertEquals(yearRange.getMinimum(), minYear, "Minimum year for Hijrah date");
    assertEquals(yearRange.getLargestMinimum(), minYear, "Largest minimum  year for Hijrah date");
    assertEquals(yearRange.getMaximum(), maxYear, "Maximum year for Hijrah date");
    assertEquals(yearRange.getSmallestMaximum(), maxYear, "Smallest maximum year for Hijrah date");

    monthRange = date.range(MONTH_OF_YEAR);
    assertEquals(monthRange.getMinimum(), minMonth, "Minimum month for HijrahDate");
    assertEquals(monthRange.getMaximum(), maxMonth, "Maximum month for HijrahDate");

    daysRange = date.range(DAY_OF_MONTH);
    assertEquals(daysRange.getMinimum(), minDay, "Minimum day for HijrahDate");
    assertEquals(daysRange.getMaximum(), maxDay, "Maximum day for HijrahDate");

}
项目:jdk8u-jdk    文件:TestUmmAlQuraChronology.java   
@DataProvider(name="dateYearDay")
Object[][] data_dateYearDay() {
    return new Object[][] {
        {HijrahChronology.INSTANCE.dateYearDay(1434, 42), HijrahChronology.INSTANCE.date(1434, 02, 13)},
        {HijrahChronology.INSTANCE.dateYearDay(1330, 354), HijrahChronology.INSTANCE.date(1330, 12, 29)},
        {HijrahChronology.INSTANCE.dateYearDay(1600, 1), HijrahChronology.INSTANCE.date(1600, 1, 1)},
        {HijrahChronology.INSTANCE.dateYearDay(1400, 175), HijrahChronology.INSTANCE.date(1400, 6, 28)},
        {HijrahChronology.INSTANCE.dateYearDay(1520, 190), HijrahChronology.INSTANCE.date(1520, 7, 13)},
        {HijrahChronology.INSTANCE.dateYearDay(1521, 112), HijrahChronology.INSTANCE.date(1521, 4, 25)},
    };
}
项目:jdk8u-jdk    文件:TestUmmAlQuraChronology.java   
@Test
public void test_getDayOfYear() {
    HijrahDate hd1 = HijrahChronology.INSTANCE.dateYearDay(1434, 1);
    for (int i = 1; i <= hd1.lengthOfYear(); i++) {
        HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1434, i);
        int doy = hd.get(DAY_OF_YEAR);
        assertEquals(doy, i, "get(DAY_OF_YEAR) incorrect for " + i);
    }
}
项目:jdk8u-jdk    文件:TestUmmAlQuraChronology.java   
@Test
public void test_withDayOfYear() {
    HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1434, 1);
    for (int i = 1; i <= hd.lengthOfYear(); i++) {
        HijrahDate hd2 = hd.with(DAY_OF_YEAR, i);
        int doy = hd2.get(DAY_OF_YEAR);
        assertEquals(doy, i, "with(DAY_OF_YEAR) incorrect for " + i + " " + hd2);
    }
}
项目:jdk8u-jdk    文件:TestUmmAlQuraChronology.java   
@Test
public void test_adjustWithDayOfWeek() {
    assertEquals(HijrahChronology.INSTANCE.date(1320, 1, 15).with(ChronoField.DAY_OF_WEEK, 4), HijrahDate.of(1320, 1, 15));
    assertEquals(HijrahChronology.INSTANCE.date(1421, 11, 15).with(ChronoField.DAY_OF_WEEK, 1), HijrahDate.of(1421, 11, 11));
    assertEquals(HijrahChronology.INSTANCE.date(1529, 7, 18).with(ChronoField.DAY_OF_WEEK, 6), HijrahDate.of(1529, 7, 20));
    assertEquals(HijrahChronology.INSTANCE.date(1534, 2, 10).with(ChronoField.DAY_OF_WEEK, 5), HijrahDate.of(1534, 2, 12));
    assertEquals(HijrahChronology.INSTANCE.date(1552, 4, 1).with(ChronoField.DAY_OF_WEEK, 2), HijrahDate.of(1552, 3, 26));
}
项目:jdk8u-jdk    文件:TestUmmAlQuraChronology.java   
@Test
public void test_adjustWithDayOfYear() {
    assertEquals(HijrahChronology.INSTANCE.date(1320, 1, 15).with(ChronoField.DAY_OF_YEAR, 24), HijrahDate.of(1320, 1, 24));
    assertEquals(HijrahChronology.INSTANCE.date(1421, 11, 15).with(ChronoField.DAY_OF_YEAR, 135), HijrahDate.of(1421, 5, 18));
    assertEquals(HijrahChronology.INSTANCE.date(1529, 7, 18).with(ChronoField.DAY_OF_YEAR, 64), HijrahDate.of(1529, 3, 5));
    assertEquals(HijrahChronology.INSTANCE.date(1534, 2, 10).with(ChronoField.DAY_OF_YEAR, 354), HijrahDate.of(1534, 12, 29));
    assertEquals(HijrahChronology.INSTANCE.date(1552, 4, 1).with(ChronoField.DAY_OF_YEAR, 291), HijrahDate.of(1552, 10, 26));
}
项目:jdk8u-jdk    文件:TestUmmAlQuraChronology.java   
@DataProvider(name="datesForPeriod")
Object[][] data_Period() {
    return new Object[][] {
        {HijrahDate.of(1350, 5, 15), HijrahDate.of(1434, 7, 20), HijrahChronology.INSTANCE.period(84, 2, 5)},
        {HijrahDate.of(1403, 5, 28), HijrahDate.of(1434, 7, 20), HijrahChronology.INSTANCE.period(31, 1, 22)},
        {HijrahDate.of(1434, 7, 20), HijrahDate.of(1484, 2, 15), HijrahChronology.INSTANCE.period(49, 6, 24)},
        {HijrahDate.of(1500, 6, 12), HijrahDate.of(1450, 4, 21), HijrahChronology.INSTANCE.period(-50, -1, -20)},
        {HijrahDate.of(1549, 3, 11), HijrahDate.of(1550, 3, 10), HijrahChronology.INSTANCE.period(0, 11, 28)},
    };
}
项目:jdk8u-jdk    文件:TestUmmAlQuraChronology.java   
@DataProvider(name="toString")
Object[][] data_toString() {
    return new Object[][] {
        {HijrahChronology.INSTANCE.date(1320, 1, 1), "Hijrah-umalqura AH 1320-01-01"},
        {HijrahChronology.INSTANCE.date(1500, 10, 28), "Hijrah-umalqura AH 1500-10-28"},
        {HijrahChronology.INSTANCE.date(1500, 10, 29), "Hijrah-umalqura AH 1500-10-29"},
        {HijrahChronology.INSTANCE.date(1434, 12, 5), "Hijrah-umalqura AH 1434-12-05"},
        {HijrahChronology.INSTANCE.date(1434, 12, 6), "Hijrah-umalqura AH 1434-12-06"},
    };
}
项目:jdk8u-jdk    文件:TestUmmAlQuraChronology.java   
@Test (dataProvider="monthDays")
public void test_valueRange_monthDays(int year, int month, int maxlength) {
    ChronoLocalDate date = HijrahChronology.INSTANCE.date(year, month, 1);
    ValueRange range = null;
    for (int i=1; i<=12; i++) {
        range = date.range(ChronoField.DAY_OF_MONTH);
        date = date.plus(1, ChronoUnit.MONTHS);
        assertEquals(range.getMaximum(), month, maxlength);
    }
}
项目:jdk8u-jdk    文件:TestUmmAlQuraChronology.java   
@Test(dataProvider="chronoDateTimes")
public void test_formatterOfLocalizedDate(int year, int month, int day, String expected) {
    HijrahDate hd = HijrahChronology.INSTANCE.date(year, month, day);
    ChronoLocalDateTime<HijrahDate> hdt = hd.atTime(LocalTime.NOON);
    hdt = hdt.plus(1, ChronoUnit.YEARS);
    hdt = hdt.plus(1, ChronoUnit.MONTHS);
    hdt = hdt.plus(1, ChronoUnit.DAYS);
    hdt = hdt.plus(1, ChronoUnit.HOURS);
    hdt = hdt.plus(1, ChronoUnit.MINUTES);
    hdt = hdt.plus(1, ChronoUnit.SECONDS);
    DateTimeFormatter df = DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG).withChronology(Chronology.of("Hijrah-umalqura")).withLocale(Locale.US);
    assertEquals(df.format(hdt), expected);
}
项目:jdk8u-jdk    文件:TestUmmAlQuraChronology.java   
@DataProvider(name="samples")
Object[][] data_samples() {
    return new Object[][] {
        {HijrahChronology.INSTANCE.date(1319, 12, 30), LocalDate.of(1902, 4, 9)},
        {HijrahChronology.INSTANCE.date(1320, 1, 1), LocalDate.of(1902, 4, 10)},
        {HijrahChronology.INSTANCE.date(1321, 12, 30), LocalDate.of(1904, 3, 18)},
        {HijrahChronology.INSTANCE.date(1433, 7, 29), LocalDate.of(2012, 6, 19)},
        {HijrahChronology.INSTANCE.date(1434, 10, 12), LocalDate.of(2013, 8, 19)},
        {HijrahChronology.INSTANCE.date(1500, 3, 3), LocalDate.of(2077, 1, 28)},
    };
}