类java.time.chrono.HijrahDate源码实例Demo

下面列出了怎么用java.time.chrono.HijrahDate的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: openjdk-jdk9   文件: 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())) ;
}
 
源代码2 项目: jdk8u-dev-jdk   文件: 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())) ;
}
 
源代码3 项目: jdk8u_jdk   文件: TestUmmAlQuraChronology.java
@DataProvider(name="dayOfWeek")
Object[][] data_dayOfweek() {
    return new Object[][] {
        {HijrahDate.of(1434, 6, 24), 1, 7},
        {HijrahDate.of(1432, 9, 3), 5, 4},
        {HijrahDate.of(1334, 12, 29), 7, 6},
        {HijrahDate.of(1354, 5, 24), 1, 7},
        {HijrahDate.of(1465, 10, 2), 2, 1},
    };
}
 
源代码4 项目: hottub   文件: 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);
}
 
源代码5 项目: openjdk-jdk9   文件: TestUmmAlQuraChronology.java
@DataProvider(name="dayOfWeek")
Object[][] data_dayOfweek() {
    return new Object[][] {
        {HijrahDate.of(1434, 6, 24), 1, 7},
        {HijrahDate.of(1432, 9, 3), 5, 4},
        {HijrahDate.of(1334, 12, 29), 7, 6},
        {HijrahDate.of(1354, 5, 24), 1, 7},
        {HijrahDate.of(1465, 10, 2), 2, 1},
    };
}
 
源代码6 项目: dragonwell8_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);
}
 
源代码7 项目: hottub   文件: 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));
}
 
@DataProvider(name="hijrahToMinguo")
Object[][] data_hijrahToMinguo() {
    return new Object[][] {
        {HijrahDate.of(1350,5,15), MinguoDate.of(20,9,28)},
        {HijrahDate.of(1434,5,1), MinguoDate.of(102,3,13)},
        {HijrahDate.of(1436,1,1), MinguoDate.of(103,10,25)},
        {HijrahDate.of(1500,6,12), MinguoDate.of(166,5,5)},
        {HijrahDate.of(1550,3,11), MinguoDate.of(214,8,11)},
    };
}
 
源代码9 项目: hottub   文件: TestUmmAlQuraChronology.java
@DataProvider(name="datesForDiff")
Object[][] data_datesForDiffs() {
    return new Object[][] {
        {HijrahDate.of(1350, 5, 15), HijrahDate.of(1351, 12, 29), 574, 19, 1},
        {HijrahDate.of(1434, 5, 1), HijrahDate.of(1434,6, 12), 40, 1, 0},
        {HijrahDate.of(1436, 1, 1), HijrahDate.of(1475, 12, 29), 14173, 479, 39},
        {HijrahDate.of(1500, 6, 12), HijrahDate.of(1551, 7, 12), 18102, 613, 51},
        {HijrahDate.of(1550, 3, 11), HijrahDate.of(1551, 4, 11), 384, 13, 1},
    };
}
 
源代码10 项目: jdk8u60   文件: TestUmmAlQuraChronology.java
@DataProvider(name="hijrahToJapanese")
Object[][] data_hijrahToJapanese() {
    return new Object[][] {
        {HijrahDate.of(1350,5,15), "Japanese Showa 6-09-28"},
        {HijrahDate.of(1434,5,1), "Japanese Heisei 25-03-13"},
        {HijrahDate.of(1436,1,1), "Japanese Heisei 26-10-25"},
        {HijrahDate.of(1500,6,12), "Japanese Heisei 89-05-05"},
        {HijrahDate.of(1550,3,11), "Japanese Heisei 137-08-11"},
    };
}
 
源代码11 项目: dragonwell8_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);
}
 
源代码12 项目: 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);
}
 
源代码13 项目: openjdk-8-source   文件: TestUmmAlQuraChronology.java
@DataProvider(name="datesForDiff")
Object[][] data_datesForDiffs() {
    return new Object[][] {
        {HijrahDate.of(1350, 5, 15), HijrahDate.of(1351, 12, 29), 574, 19, 1},
        {HijrahDate.of(1434, 5, 1), HijrahDate.of(1434,6, 12), 40, 1, 0},
        {HijrahDate.of(1436, 1, 1), HijrahDate.of(1475, 12, 29), 14173, 479, 39},
        {HijrahDate.of(1500, 6, 12), HijrahDate.of(1551, 7, 12), 18102, 613, 51},
        {HijrahDate.of(1550, 3, 11), HijrahDate.of(1551, 4, 11), 384, 13, 1},
    };
}
 
源代码14 项目: jdk8u60   文件: 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);
}
 
@Test()
public void test_hijrahSerialization_format() throws Exception {
    HijrahChronology chrono = HijrahChronology.INSTANCE;
    HijrahDate date = HijrahDate.of(1433, 10, 29);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    // Expect the type of the HijrahDate in the stream
    byte[] hijrahDateBytes = new byte[] {HIJRAH_DATE_TYPE};

    // Literal reference to Hijrah-Umalqura Chronology
    byte[] hijrahChronoBytes = new byte[] {
        115, 113, 0, 126, 0, 0,                        /* p w \u0001 \u0006 s q \u0000 ~ \u0000 \u0000 */
        119, 18, 1, 0, 15, 72, 105, 106, 114, 97,      /* w \u0012 \u0001 \u0000 \u000f H i j r a */
        104, 45, 117, 109, 97, 108, 113, 117, 114, 97, /* h - u m a l q u r a */
        120,                                           /*  \u001d x */
    };

    // Build the sequence that represents the data in the stream
    baos = new ByteArrayOutputStream();
    try (DataOutputStream dos = new DataOutputStream(baos) ) {
        dos.writeByte(ObjectStreamConstants.TC_BLOCKDATA);
        dos.writeByte(6);   // 6 bytes follow
        dos.writeInt(date.get(YEAR));
        dos.writeByte(date.get(MONTH_OF_YEAR));
        dos.writeByte(date.get(DAY_OF_MONTH));
        dos.writeByte(ObjectStreamConstants.TC_ENDBLOCKDATA);
    }
    byte[] dateBytes = baos.toByteArray();

    assertSerializedBySer(date, hijrahDateBytes, hijrahChronoBytes, dateBytes);
}
 
源代码16 项目: openjdk-jdk9   文件: 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);
}
 
源代码17 项目: jdk8u60   文件: TestUmmAlQuraChronology.java
@DataProvider(name="datesForDiff")
Object[][] data_datesForDiffs() {
    return new Object[][] {
        {HijrahDate.of(1350, 5, 15), HijrahDate.of(1351, 12, 29), 574, 19, 1},
        {HijrahDate.of(1434, 5, 1), HijrahDate.of(1434,6, 12), 40, 1, 0},
        {HijrahDate.of(1436, 1, 1), HijrahDate.of(1475, 12, 29), 14173, 479, 39},
        {HijrahDate.of(1500, 6, 12), HijrahDate.of(1551, 7, 12), 18102, 613, 51},
        {HijrahDate.of(1550, 3, 11), HijrahDate.of(1551, 4, 11), 384, 13, 1},
    };
}
 
源代码18 项目: 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);
}
 
源代码19 项目: jdk8u-jdk   文件: 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));
}
 
源代码20 项目: openjdk-jdk8u   文件: 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));
}
 
源代码21 项目: jdk8u-dev-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");

}
 
源代码22 项目: hottub   文件: 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);
}
 
源代码23 项目: 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);
}
 
@Test()
public void test_hijrahSerialization_format() throws Exception {
    HijrahChronology chrono = HijrahChronology.INSTANCE;
    HijrahDate date = HijrahDate.of(1433, 10, 29);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    // Expect the type of the HijrahDate in the stream
    byte[] hijrahDateBytes = new byte[] {HIJRAH_DATE_TYPE};

    // Literal reference to Hijrah-Umalqura Chronology
    byte[] hijrahChronoBytes = new byte[] {
        115, 113, 0, 126, 0, 0,                        /* p w \u0001 \u0006 s q \u0000 ~ \u0000 \u0000 */
        119, 18, 1, 0, 15, 72, 105, 106, 114, 97,      /* w \u0012 \u0001 \u0000 \u000f H i j r a */
        104, 45, 117, 109, 97, 108, 113, 117, 114, 97, /* h - u m a l q u r a */
        120,                                           /*  \u001d x */
    };

    // Build the sequence that represents the data in the stream
    baos = new ByteArrayOutputStream();
    try (DataOutputStream dos = new DataOutputStream(baos) ) {
        dos.writeByte(ObjectStreamConstants.TC_BLOCKDATA);
        dos.writeByte(6);   // 6 bytes follow
        dos.writeInt(date.get(YEAR));
        dos.writeByte(date.get(MONTH_OF_YEAR));
        dos.writeByte(date.get(DAY_OF_MONTH));
        dos.writeByte(ObjectStreamConstants.TC_ENDBLOCKDATA);
    }
    byte[] dateBytes = baos.toByteArray();

    assertSerializedBySer(date, hijrahDateBytes, hijrahChronoBytes, dateBytes);
}
 
源代码25 项目: openjdk-8   文件: TestUmmAlQuraChronology.java
@DataProvider(name = "dates")
Object[][] data_dates() {
    return new Object[][]{
        {HijrahDate.of(1300, 5, 1), 1300, 1600, 1, 12, 1, 30, 30},
        {HijrahDate.of(1300, 6, 1), 1300, 1600, 1, 12, 1, 29, 30},
        {HijrahDate.of(1434, 12, 1), 1300, 1600, 1, 12, 1, 29, 30},
        {HijrahDate.of(1500, 4, 1), 1300, 1600, 1, 12, 1, 30, 30},
        {HijrahDate.of(1600, 6, 1), 1300, 1600, 1, 12, 1, 29, 30},
    };
}
 
源代码26 项目: openjdk-8-source   文件: 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");

}
 
源代码27 项目: hottub   文件: TCKChronoLocalDateSerialization.java
@Test()
public void test_hijrahSerialization_format() throws Exception {
    HijrahChronology chrono = HijrahChronology.INSTANCE;
    HijrahDate date = HijrahDate.of(1433, 10, 29);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    // Expect the type of the HijrahDate in the stream
    byte[] hijrahDateBytes = new byte[] {HIJRAH_DATE_TYPE};

    // Literal reference to Hijrah-Umalqura Chronology
    byte[] hijrahChronoBytes = new byte[] {
        115, 113, 0, 126, 0, 0,                        /* p w \u0001 \u0006 s q \u0000 ~ \u0000 \u0000 */
        119, 18, 1, 0, 15, 72, 105, 106, 114, 97,      /* w \u0012 \u0001 \u0000 \u000f H i j r a */
        104, 45, 117, 109, 97, 108, 113, 117, 114, 97, /* h - u m a l q u r a */
        120,                                           /*  \u001d x */
    };

    // Build the sequence that represents the data in the stream
    baos = new ByteArrayOutputStream();
    try (DataOutputStream dos = new DataOutputStream(baos) ) {
        dos.writeByte(ObjectStreamConstants.TC_BLOCKDATA);
        dos.writeByte(6);   // 6 bytes follow
        dos.writeInt(date.get(YEAR));
        dos.writeByte(date.get(MONTH_OF_YEAR));
        dos.writeByte(date.get(DAY_OF_MONTH));
        dos.writeByte(ObjectStreamConstants.TC_ENDBLOCKDATA);
    }
    byte[] dateBytes = baos.toByteArray();

    assertSerializedBySer(date, hijrahDateBytes, hijrahChronoBytes, dateBytes);
}
 
源代码28 项目: openjdk-8-source   文件: 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);
}
 
源代码29 项目: jdk8u-dev-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));
}
 
源代码30 项目: openjdk-jdk8u   文件: 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);
}
 
 类所在包
 同包方法