firstDayOfWeek = DayOfWeek.of(firstDayOfWeekInt); } else { firstDayOfWeek = WeekFields.of(Locale.getDefault()).getFirstDayOfWeek();
/** * Obtains an instance of {@code DayOfWeek} from a temporal object. * <p> * A {@code TemporalAccessor} represents some form of date and time information. * This factory converts the arbitrary temporal object to an instance of {@code DayOfWeek}. * <p> * The conversion extracts the {@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} field. * <p> * This method matches the signature of the functional interface {@link TemporalQuery} * allowing it to be used as a query via method reference, {@code DayOfWeek::from}. * * @param temporal the temporal object to convert, not null * @return the day-of-week, not null * @throws DateTimeException if unable to convert to a {@code DayOfWeek} */ public static DayOfWeek from(TemporalAccessor temporal) { if (temporal instanceof DayOfWeek) { return (DayOfWeek) temporal; } try { return of(temporal.get(DAY_OF_WEEK)); } catch (DateTimeException ex) { throw new DateTimeException("Unable to obtain DayOfWeek from TemporalAccessor: " + temporal + ", type " + temporal.getClass().getName(), ex); } }
/** * Obtains an instance of {@code DayOfWeek} from a temporal object. * <p> * A {@code TemporalAccessor} represents some form of date and time information. * This factory converts the arbitrary temporal object to an instance of {@code DayOfWeek}. * <p> * The conversion extracts the {@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} field. * <p> * This method matches the signature of the functional interface {@link TemporalQuery} * allowing it to be used as a query via method reference, {@code DayOfWeek::from}. * * @param temporal the temporal object to convert, not null * @return the day-of-week, not null * @throws DateTimeException if unable to convert to a {@code DayOfWeek} */ public static DayOfWeek from(TemporalAccessor temporal) { if (temporal instanceof DayOfWeek) { return (DayOfWeek) temporal; } try { return of(temporal.get(DAY_OF_WEEK)); } catch (DateTimeException ex) { throw new DateTimeException("Unable to obtain DayOfWeek from TemporalAccessor: " + temporal + ", type " + temporal.getClass().getName(), ex); } }
/** * Gets the day-of-week field, which is an enum {@code DayOfWeek}. * <p> * This method returns the enum {@link DayOfWeek} for the day-of-week. * This avoids confusion as to what {@code int} values mean. * If you need access to the primitive {@code int} value then the enum * provides the {@link DayOfWeek#getValue() int value}. * <p> * Additional information can be obtained from the {@code DayOfWeek}. * This includes textual names of the values. * * @return the day-of-week, not null */ public DayOfWeek getDayOfWeek() { int dow0 = Jdk8Methods.floorMod(toEpochDay() + 3, 7); return DayOfWeek.of(dow0 + 1); }
/** * Gets the day-of-week field, which is an enum {@code DayOfWeek}. * <p> * This method returns the enum {@link DayOfWeek} for the day-of-week. * This avoids confusion as to what {@code int} values mean. * If you need access to the primitive {@code int} value then the enum * provides the {@link DayOfWeek#getValue() int value}. * <p> * Additional information can be obtained from the {@code DayOfWeek}. * This includes textual names of the values. * * @return the day-of-week, not null */ public DayOfWeek getDayOfWeek() { int dow0 = Jdk8Methods.floorMod(toEpochDay() + 3, 7); return DayOfWeek.of(dow0 + 1); }
setFirstDayOfWeek(DayOfWeek.of(dayOfWeekValue)); setState(attrs.getInt(R.styleable.UICalendar_state, mState));
/** * Reads the state from the stream. * * @param in the input stream, not null * @return the created object, not null * @throws IOException if an error occurs */ static ZoneOffsetTransitionRule readExternal(DataInput in) throws IOException { int data = in.readInt(); Month month = Month.of(data >>> 28); int dom = ((data & (63 << 22)) >>> 22) - 32; int dowByte = (data & (7 << 19)) >>> 19; DayOfWeek dow = dowByte == 0 ? null : DayOfWeek.of(dowByte); int timeByte = (data & (31 << 14)) >>> 14; TimeDefinition defn = TimeDefinition.values()[(data & (3 << 12)) >>> 12]; int stdByte = (data & (255 << 4)) >>> 4; int beforeByte = (data & (3 << 2)) >>> 2; int afterByte = (data & 3); int timeOfDaysSecs = (timeByte == 31 ? in.readInt() : timeByte * 3600); ZoneOffset std = (stdByte == 255 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds((stdByte - 128) * 900)); ZoneOffset before = (beforeByte == 3 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(std.getTotalSeconds() + beforeByte * 1800)); ZoneOffset after = (afterByte == 3 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(std.getTotalSeconds() + afterByte * 1800)); // only bit of validation that we need to copy from public of() method if (dom < -28 || dom > 31 || dom == 0) { throw new IllegalArgumentException("Day of month indicator must be between -28 and 31 inclusive excluding zero"); } LocalTime time = LocalTime.ofSecondOfDay(Jdk8Methods.floorMod(timeOfDaysSecs, SECS_PER_DAY)); int adjustDays = Jdk8Methods.floorDiv(timeOfDaysSecs, SECS_PER_DAY); return new ZoneOffsetTransitionRule(month, dom, dow, time, adjustDays, defn, std, before, after); }
/** * Reads the state from the stream. * * @param in the input stream, not null * @return the created object, not null * @throws IOException if an error occurs */ static ZoneOffsetTransitionRule readExternal(DataInput in) throws IOException { int data = in.readInt(); Month month = Month.of(data >>> 28); int dom = ((data & (63 << 22)) >>> 22) - 32; int dowByte = (data & (7 << 19)) >>> 19; DayOfWeek dow = dowByte == 0 ? null : DayOfWeek.of(dowByte); int timeByte = (data & (31 << 14)) >>> 14; TimeDefinition defn = TimeDefinition.values()[(data & (3 << 12)) >>> 12]; int stdByte = (data & (255 << 4)) >>> 4; int beforeByte = (data & (3 << 2)) >>> 2; int afterByte = (data & 3); int timeOfDaysSecs = (timeByte == 31 ? in.readInt() : timeByte * 3600); ZoneOffset std = (stdByte == 255 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds((stdByte - 128) * 900)); ZoneOffset before = (beforeByte == 3 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(std.getTotalSeconds() + beforeByte * 1800)); ZoneOffset after = (afterByte == 3 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(std.getTotalSeconds() + afterByte * 1800)); // only bit of validation that we need to copy from public of() method if (dom < -28 || dom > 31 || dom == 0) { throw new IllegalArgumentException("Day of month indicator must be between -28 and 31 inclusive excluding zero"); } LocalTime time = LocalTime.ofSecondOfDay(Jdk8Methods.floorMod(timeOfDaysSecs, SECS_PER_DAY)); int adjustDays = Jdk8Methods.floorDiv(timeOfDaysSecs, SECS_PER_DAY); return new ZoneOffsetTransitionRule(month, dom, dow, time, adjustDays, defn, std, before, after); }
/** * 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); }
int aw = ALIGNED_WEEK_OF_MONTH.checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_MONTH)); int dow = DAY_OF_WEEK.checkValidIntValue(fieldValues.remove(DAY_OF_WEEK)); JapaneseDate date = date(y, moy, 1).plus(aw - 1, WEEKS).with(nextOrSame(DayOfWeek.of(dow))); if (resolverStyle == ResolverStyle.STRICT && date.get(MONTH_OF_YEAR) != moy) { throw new DateTimeException("Strict mode rejected date parsed to a different month"); JapaneseDate date = date(y, 1, 1).plus(aw - 1, WEEKS).with(nextOrSame(DayOfWeek.of(dow))); if (resolverStyle == ResolverStyle.STRICT && date.get(YEAR) != y) { throw new DateTimeException("Strict mode rejected date parsed to a different month");
/** * 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); }
int aw = ALIGNED_WEEK_OF_MONTH.checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_MONTH)); int dow = DAY_OF_WEEK.checkValidIntValue(fieldValues.remove(DAY_OF_WEEK)); JapaneseDate date = date(y, moy, 1).plus(aw - 1, WEEKS).with(nextOrSame(DayOfWeek.of(dow))); if (resolverStyle == ResolverStyle.STRICT && date.get(MONTH_OF_YEAR) != moy) { throw new DateTimeException("Strict mode rejected date parsed to a different month"); JapaneseDate date = date(y, 1, 1).plus(aw - 1, WEEKS).with(nextOrSame(DayOfWeek.of(dow))); if (resolverStyle == ResolverStyle.STRICT && date.get(YEAR) != y) { throw new DateTimeException("Strict mode rejected date parsed to a different month");
int aw = ALIGNED_WEEK_OF_MONTH.checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_MONTH)); int dow = DAY_OF_WEEK.checkValidIntValue(fieldValues.remove(DAY_OF_WEEK)); HijrahDate date = date(y, moy, 1).plus(aw - 1, WEEKS).with(nextOrSame(DayOfWeek.of(dow))); if (resolverStyle == ResolverStyle.STRICT && date.get(MONTH_OF_YEAR) != moy) { throw new DateTimeException("Strict mode rejected date parsed to a different month"); HijrahDate date = date(y, 1, 1).plus(aw - 1, WEEKS).with(nextOrSame(DayOfWeek.of(dow))); if (resolverStyle == ResolverStyle.STRICT && date.get(YEAR) != y) { throw new DateTimeException("Strict mode rejected date parsed to a different month");
int aw = ALIGNED_WEEK_OF_MONTH.checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_MONTH)); int dow = DAY_OF_WEEK.checkValidIntValue(fieldValues.remove(DAY_OF_WEEK)); MinguoDate date = date(y, moy, 1).plus(aw - 1, WEEKS).with(nextOrSame(DayOfWeek.of(dow))); if (resolverStyle == ResolverStyle.STRICT && date.get(MONTH_OF_YEAR) != moy) { throw new DateTimeException("Strict mode rejected date parsed to a different month"); MinguoDate date = date(y, 1, 1).plus(aw - 1, WEEKS).with(nextOrSame(DayOfWeek.of(dow))); if (resolverStyle == ResolverStyle.STRICT && date.get(YEAR) != y) { throw new DateTimeException("Strict mode rejected date parsed to a different month");
int aw = ALIGNED_WEEK_OF_MONTH.checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_MONTH)); int dow = DAY_OF_WEEK.checkValidIntValue(fieldValues.remove(DAY_OF_WEEK)); ThaiBuddhistDate date = date(y, moy, 1).plus(aw - 1, WEEKS).with(nextOrSame(DayOfWeek.of(dow))); if (resolverStyle == ResolverStyle.STRICT && date.get(MONTH_OF_YEAR) != moy) { throw new DateTimeException("Strict mode rejected date parsed to a different month"); ThaiBuddhistDate date = date(y, 1, 1).plus(aw - 1, WEEKS).with(nextOrSame(DayOfWeek.of(dow))); if (resolverStyle == ResolverStyle.STRICT && date.get(YEAR) != y) { throw new DateTimeException("Strict mode rejected date parsed to a different month");
int aw = ALIGNED_WEEK_OF_MONTH.checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_MONTH)); int dow = DAY_OF_WEEK.checkValidIntValue(fieldValues.remove(DAY_OF_WEEK)); ThaiBuddhistDate date = date(y, moy, 1).plus(aw - 1, WEEKS).with(nextOrSame(DayOfWeek.of(dow))); if (resolverStyle == ResolverStyle.STRICT && date.get(MONTH_OF_YEAR) != moy) { throw new DateTimeException("Strict mode rejected date parsed to a different month"); ThaiBuddhistDate date = date(y, 1, 1).plus(aw - 1, WEEKS).with(nextOrSame(DayOfWeek.of(dow))); if (resolverStyle == ResolverStyle.STRICT && date.get(YEAR) != y) { throw new DateTimeException("Strict mode rejected date parsed to a different month");
int aw = ALIGNED_WEEK_OF_MONTH.checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_MONTH)); int dow = DAY_OF_WEEK.checkValidIntValue(fieldValues.remove(DAY_OF_WEEK)); MinguoDate date = date(y, moy, 1).plus(aw - 1, WEEKS).with(nextOrSame(DayOfWeek.of(dow))); if (resolverStyle == ResolverStyle.STRICT && date.get(MONTH_OF_YEAR) != moy) { throw new DateTimeException("Strict mode rejected date parsed to a different month"); MinguoDate date = date(y, 1, 1).plus(aw - 1, WEEKS).with(nextOrSame(DayOfWeek.of(dow))); if (resolverStyle == ResolverStyle.STRICT && date.get(YEAR) != y) { throw new DateTimeException("Strict mode rejected date parsed to a different month");
int aw = ALIGNED_WEEK_OF_MONTH.checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_MONTH)); int dow = DAY_OF_WEEK.checkValidIntValue(fieldValues.remove(DAY_OF_WEEK)); HijrahDate date = date(y, moy, 1).plus(aw - 1, WEEKS).with(nextOrSame(DayOfWeek.of(dow))); if (resolverStyle == ResolverStyle.STRICT && date.get(MONTH_OF_YEAR) != moy) { throw new DateTimeException("Strict mode rejected date parsed to a different month"); HijrahDate date = date(y, 1, 1).plus(aw - 1, WEEKS).with(nextOrSame(DayOfWeek.of(dow))); if (resolverStyle == ResolverStyle.STRICT && date.get(YEAR) != y) { throw new DateTimeException("Strict mode rejected date parsed to a different month");
int aw = ALIGNED_WEEK_OF_MONTH.checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_MONTH)); int dow = DAY_OF_WEEK.checkValidIntValue(fieldValues.remove(DAY_OF_WEEK)); LocalDate date = LocalDate.of(y, moy, 1).plusWeeks(aw - 1).with(nextOrSame(DayOfWeek.of(dow))); if (resolverStyle == ResolverStyle.STRICT && date.get(MONTH_OF_YEAR) != moy) { throw new DateTimeException("Strict mode rejected date parsed to a different month"); LocalDate date = LocalDate.of(y, 1, 1).plusWeeks(aw - 1).with(nextOrSame(DayOfWeek.of(dow))); if (resolverStyle == ResolverStyle.STRICT && date.get(YEAR) != y) { throw new DateTimeException("Strict mode rejected date parsed to a different month");
int aw = ALIGNED_WEEK_OF_MONTH.checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_MONTH)); int dow = DAY_OF_WEEK.checkValidIntValue(fieldValues.remove(DAY_OF_WEEK)); LocalDate date = LocalDate.of(y, moy, 1).plusWeeks(aw - 1).with(nextOrSame(DayOfWeek.of(dow))); if (resolverStyle == ResolverStyle.STRICT && date.get(MONTH_OF_YEAR) != moy) { throw new DateTimeException("Strict mode rejected date parsed to a different month"); LocalDate date = LocalDate.of(y, 1, 1).plusWeeks(aw - 1).with(nextOrSame(DayOfWeek.of(dow))); if (resolverStyle == ResolverStyle.STRICT && date.get(YEAR) != y) { throw new DateTimeException("Strict mode rejected date parsed to a different month");