/** * Obtains an instance of {@code HijrahDate} from the era, year-of-era * month-of-year and day-of-month. * * @param era the era to represent, not null * @param yearOfEra the year-of-era to represent, from 1 to 9999 * @param monthOfYear the month-of-year to represent, from 1 to 12 * @param dayOfMonth the day-of-month to represent, from 1 to 31 * @return the Hijrah date, never null * @throws IllegalCalendarFieldValueException if the value of any field is out of range * @throws InvalidCalendarFieldException if the day-of-month is invalid for the month-year */ static HijrahDate of(HijrahEra era, int yearOfEra, int monthOfYear, int dayOfMonth) { Jdk8Methods.requireNonNull(era, "era"); checkValidYearOfEra(yearOfEra); checkValidMonth(monthOfYear); checkValidDayOfMonth(dayOfMonth); long gregorianDays = getGregorianEpochDay(era.prolepticYear(yearOfEra), monthOfYear, dayOfMonth); return new HijrahDate(gregorianDays); }
/** * Constructs an instance with the specified date. * * @param gregorianDay the number of days from 0001/01/01 (Gregorian), caller calculated */ private HijrahDate(long gregorianDay) { int[] dateInfo = getHijrahDateInfo(gregorianDay); checkValidYearOfEra(dateInfo[1]); checkValidMonth(dateInfo[2]); checkValidDayOfMonth(dateInfo[3]); checkValidDayOfYear(dateInfo[4]); this.era = HijrahEra.of(dateInfo[0]); this.yearOfEra = dateInfo[1]; this.monthOfYear = dateInfo[2]; this.dayOfMonth = dateInfo[3]; this.dayOfYear = dateInfo[4]; this.dayOfWeek = DayOfWeek.of(dateInfo[5]); this.gregorianEpochDay = gregorianDay; this.isLeapYear = isLeapYear(this.yearOfEra); }