java.time.chrono.HijrahChronology Java Examples
The following examples show how to use
java.time.chrono.HijrahChronology.
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 dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@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"); }
Example #2
Source File: TestReducedParser.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@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)}, }; }
Example #3
Source File: TestUmmAlQuraChronology.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@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"); }
Example #4
Source File: TCKHijrahChronology.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@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())) ; }
Example #5
Source File: TestReducedParser.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@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)}, }; }
Example #6
Source File: TestChronologyPerf.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@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); }
Example #7
Source File: TCKHijrahChronology.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@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())) ; }
Example #8
Source File: TestUmmAlQuraChronology.java From hottub with GNU General Public License v2.0 | 5 votes |
@DataProvider(name="datesForComparison") Object[][] data_datesForComparison() { return new Object[][] { {HijrahChronology.INSTANCE.date(1434, 6, 26), LocalDate.of(2013, 5, 5), -1, 1}, {HijrahChronology.INSTANCE.date(1433, 4, 15), LocalDate.of(2012, 3, 15), 1, -1}, {HijrahChronology.INSTANCE.date(1432, 5, 21), LocalDate.of(2011, 4, 22), -1, 1}, {HijrahChronology.INSTANCE.date(1433, 7, 29), LocalDate.of(2012, 6, 2), -1, 1}, {HijrahChronology.INSTANCE.date(1434, 10, 12), LocalDate.of(2013, 8, 2), -1, 1}, }; }
Example #9
Source File: TCKChronologySerialization.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "calendars") Chronology[][] data_of_calendars() { return new Chronology[][]{ {HijrahChronology.INSTANCE}, {IsoChronology.INSTANCE}, {JapaneseChronology.INSTANCE}, {MinguoChronology.INSTANCE}, {ThaiBuddhistChronology.INSTANCE}}; }
Example #10
Source File: TestExampleCode.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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); }
Example #11
Source File: TestUmmAlQuraChronology.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@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"); }
Example #12
Source File: TCKHijrahChronology.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@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); }
Example #13
Source File: TCKHijrahChronology.java From hottub with GNU General Public License v2.0 | 5 votes |
@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); }
Example #14
Source File: TCKChronoZonedDateTimeSerialization.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "calendars") Chronology[][] data_of_calendars() { return new Chronology[][]{ {HijrahChronology.INSTANCE}, {IsoChronology.INSTANCE}, {JapaneseChronology.INSTANCE}, {MinguoChronology.INSTANCE}, {ThaiBuddhistChronology.INSTANCE}, }; }
Example #15
Source File: TCKChronoZonedDateTimeSerialization.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "calendars") Chronology[][] data_of_calendars() { return new Chronology[][]{ {HijrahChronology.INSTANCE}, {IsoChronology.INSTANCE}, {JapaneseChronology.INSTANCE}, {MinguoChronology.INSTANCE}, {ThaiBuddhistChronology.INSTANCE}, }; }
Example #16
Source File: TCKHijrahChronology.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@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); }
Example #17
Source File: TCKChronoLocalDate.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "calendars") Chronology[][] data_of_calendars() { return new Chronology[][]{ {HijrahChronology.INSTANCE}, {IsoChronology.INSTANCE}, {JapaneseChronology.INSTANCE}, {MinguoChronology.INSTANCE}, {ThaiBuddhistChronology.INSTANCE}}; }
Example #18
Source File: TestUmmAlQuraChronology.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@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); } }
Example #19
Source File: TestUmmAlQuraChronology.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@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"}, }; }
Example #20
Source File: TestUmmAlQuraChronology.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@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)); }
Example #21
Source File: TestUmmAlQuraChronology.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@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); } }
Example #22
Source File: TCKHijrahChronology.java From hottub with GNU General Public License v2.0 | 5 votes |
@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); }
Example #23
Source File: TCKChronologySerialization.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "invalidSerialformClasses") Object[][] invalid_serial_classes() { return new Object[][]{ {IsoChronology.class}, {JapaneseChronology.class}, {MinguoChronology.class}, {ThaiBuddhistChronology.class}, {HijrahChronology.class}, }; }
Example #24
Source File: TCKChronoLocalDate.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "calendars") Chronology[][] data_of_calendars() { return new Chronology[][]{ {HijrahChronology.INSTANCE}, {IsoChronology.INSTANCE}, {JapaneseChronology.INSTANCE}, {MinguoChronology.INSTANCE}, {ThaiBuddhistChronology.INSTANCE}}; }
Example #25
Source File: TCKChronologySerialization.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "calendars") Chronology[][] data_of_calendars() { return new Chronology[][]{ {HijrahChronology.INSTANCE}, {IsoChronology.INSTANCE}, {JapaneseChronology.INSTANCE}, {MinguoChronology.INSTANCE}, {ThaiBuddhistChronology.INSTANCE}}; }
Example #26
Source File: TestUmmAlQuraChronology.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@DataProvider(name="zonedDateTime") Object[][] data_zonedDateTime() { return new Object[][] { {ZonedDateTime.of(2012, 2, 29, 2, 7, 1, 1, ZONE_RIYADH), HijrahChronology.INSTANCE.date(1433, 4, 7), LocalTime.of(2, 7, 1, 1), null}, {OffsetDateTime.of(2012, 2, 29, 2, 7, 1, 1, OFFSET_PTWO), HijrahChronology.INSTANCE.date(1433, 4, 7), 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}, }; }
Example #27
Source File: TCKHijrahChronology.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@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); }
Example #28
Source File: TCKChronoLocalDateSerialization.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@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 #29
Source File: TestUmmAlQuraChronology.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@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); }
Example #30
Source File: TestUmmAlQuraChronology.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Test public void test_chronoFields() { ChronoLocalDate hdate = HijrahChronology.INSTANCE.date(1434, 6, 28); assertEquals(hdate.get(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH), 3); assertEquals(hdate.get(ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR), 7); assertEquals(hdate.get(ChronoField.ALIGNED_WEEK_OF_MONTH), 4); assertEquals(hdate.get(ChronoField.ALIGNED_WEEK_OF_YEAR), 25); assertEquals(hdate.get(ChronoField.ERA), 1); assertEquals(hdate.get(ChronoField.YEAR_OF_ERA), 1434); assertEquals(hdate.get(ChronoField.MONTH_OF_YEAR), 6); assertEquals(hdate.get(ChronoField.DAY_OF_MONTH), 28); assertEquals(hdate.get(ChronoField.DAY_OF_WEEK), 3); assertEquals(hdate.get(ChronoField.DAY_OF_YEAR), 175); }