APISonar


java.time.chrono.HijrahChronology.INSTANCE.date

> java > time > chrono > HijrahChronology > INSTANCE > date
java APIs time APIs chrono APIs HijrahChronology APIs INSTANCE APIs date APIs

Example 1
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);
        }
    }
Example 2
public void test_alignedWeekOfMonth(int year, int month, int dom, int wom, int dowm) {
        HijrahDate date = HijrahChronology.INSTANCE.date(year, month, dom);
        assertEquals(date.getLong(ChronoField.ALIGNED_WEEK_OF_MONTH), wom);
    }
Example 3
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 4
public void test_lastDayOfMonth(int year, int month, int numDays) {
        HijrahDate hDate = HijrahChronology.INSTANCE.date(year, month, 1);
        hDate = hDate.with(TemporalAdjusters.lastDayOfMonth());
        assertEquals(hDate.get(ChronoField.DAY_OF_MONTH), numDays);
    }
Example 5
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 6
public void test_chronoFields() {
        ChronoLocalDate hdate = HijrahChronology.INSTANCE.date(1434, 6, 28);
        assertEquals(hdate.get(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH), 7);
        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);
    }
Example 7
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);
    }