Java Code Examples for java.time.chrono.HijrahDate#of()

The following examples show how to use java.time.chrono.HijrahDate#of() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestUmmAlQuraChronology.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name="hijrahToThai")
Object[][] data_hijrahToThai() {
    return new Object[][] {
        {HijrahDate.of(1350,5,15), ThaiBuddhistDate.of(2474,9,28)},
        {HijrahDate.of(1434,5,1), ThaiBuddhistDate.of(2556,3,13)},
        {HijrahDate.of(1436,1,1), ThaiBuddhistDate.of(2557,10,25)},
        {HijrahDate.of(1500,6,12), ThaiBuddhistDate.of(2620,5,5)},
        {HijrahDate.of(1550,3,11), ThaiBuddhistDate.of(2668,8,11)},
    };
}
 
Example 2
Source File: TestUmmAlQuraChronology.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@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},
    };
}
 
Example 3
Source File: TestUmmAlQuraChronology.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@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)},
    };
}
 
Example 4
Source File: TestUmmAlQuraChronology.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@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)},
    };
}
 
Example 5
Source File: TestUmmAlQuraChronology.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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},
    };
}
 
Example 6
Source File: TestUmmAlQuraChronology.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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},
    };
}
 
Example 7
Source File: TestUmmAlQuraChronology.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "UmmAlQuraVsISODates")
Object[][] data_UmmAlQuraVsISODates() {
    return new Object[][] {
        {HijrahDate.of(1318, 1, 1), LocalDate.of(1900, 04, 30)},
        {HijrahDate.of(1318, 12, 29), LocalDate.of(1901, 04, 19)},
        {HijrahDate.of(1319, 01, 01), LocalDate.of(1901, 04, 20)},
        {HijrahDate.of(1433, 12, 29), LocalDate.of(2012, 11, 14)},
        {HijrahDate.of(1434, 01, 01), LocalDate.of(2012, 11, 15)},
        {HijrahDate.of(1434, 02, 18), LocalDate.of(2012, 12, 31)},
        {HijrahDate.of(1502, 12, 29), LocalDate.of(2079, 10, 25)},
    };
}
 
Example 8
Source File: TestUmmAlQuraChronology.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name="hijrahToThai")
Object[][] data_hijrahToThai() {
    return new Object[][] {
        {HijrahDate.of(1350,5,15), ThaiBuddhistDate.of(2474,9,28)},
        {HijrahDate.of(1434,5,1), ThaiBuddhistDate.of(2556,3,13)},
        {HijrahDate.of(1436,1,1), ThaiBuddhistDate.of(2557,10,25)},
        {HijrahDate.of(1500,6,12), ThaiBuddhistDate.of(2620,5,5)},
        {HijrahDate.of(1550,3,11), ThaiBuddhistDate.of(2668,8,11)},
    };
}
 
Example 9
Source File: TestUmmAlQuraChronology.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_temporalDayAdjustments() {
    HijrahDate date = HijrahDate.of(1554, 7, 21);
    assertEquals(date.with(TemporalAdjusters.firstDayOfMonth()), HijrahDate.of(1554, 7, 1));
    assertEquals(date.with(TemporalAdjusters.lastDayOfMonth()), HijrahDate.of(1554, 7, 29));
    assertEquals(date.with(TemporalAdjusters.firstDayOfNextMonth()), HijrahDate.of(1554, 8, 1));
    assertEquals(date.with(TemporalAdjusters.firstDayOfNextYear()), HijrahDate.of(1555, 1, 1));
    assertEquals(date.with(TemporalAdjusters.firstDayOfYear()), HijrahDate.of(1554, 1, 1));
    assertEquals(date.with(TemporalAdjusters.lastDayOfYear()), HijrahDate.of(1554, 12, 30));
}
 
Example 10
Source File: TCKChronoLocalDateSerialization.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example 11
Source File: TestUmmAlQuraChronology.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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},
    };
}
 
Example 12
Source File: TestUmmAlQuraChronology.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@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},
    };
}
 
Example 13
Source File: TestUmmAlQuraChronology.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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)},
    };
}
 
Example 14
Source File: TestUmmAlQuraChronology.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name="hijrahToThai")
Object[][] data_hijrahToThai() {
    return new Object[][] {
        {HijrahDate.of(1350,5,15), ThaiBuddhistDate.of(2474,9,28)},
        {HijrahDate.of(1434,5,1), ThaiBuddhistDate.of(2556,3,13)},
        {HijrahDate.of(1436,1,1), ThaiBuddhistDate.of(2557,10,25)},
        {HijrahDate.of(1500,6,12), ThaiBuddhistDate.of(2620,5,5)},
        {HijrahDate.of(1550,3,11), ThaiBuddhistDate.of(2668,8,11)},
    };
}
 
Example 15
Source File: TestUmmAlQuraChronology.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@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"},
    };
}
 
Example 16
Source File: TestUmmAlQuraChronology.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@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},
    };
}
 
Example 17
Source File: TestUmmAlQuraChronology.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="epochDays")
public void test_epochDays(int y, long epoch) {
    HijrahDate date = HijrahDate.of(y, 1, 1);
    assertEquals(date.toEpochDay(), epoch);
}
 
Example 18
Source File: TCKHijrahChronology.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private static HijrahDate date(int y, int m, int d) {
    return HijrahDate.of(y, m, d);
}
 
Example 19
Source File: TestUmmAlQuraChronology.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="leapYears")
public void test_leapYears(int y, boolean leapyear) {
    HijrahDate date = HijrahDate.of(y, 1, 1);
    assertEquals(date.isLeapYear(), leapyear);
}
 
Example 20
Source File: TestUmmAlQuraChronology.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="epochDays")
public void test_epochDays(int y, long epoch) {
    HijrahDate date = HijrahDate.of(y, 1, 1);
    assertEquals(date.toEpochDay(), epoch);
}