/** * Get the day * * @return the day of the month for this day */ public int getDay() { return date.getDayOfMonth(); }
@Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(date.getYear()); dest.writeInt(date.getMonthValue()); dest.writeInt(date.getDayOfMonth()); }
@Override public String toString() { return "CalendarDay{" + date.getYear() + "-" + date.getMonthValue() + "-" + date.getDayOfMonth() + "}"; }
@Override public int hashCode() { return hashCode(date.getYear(), date.getMonthValue(), date.getDayOfMonth()); }
/** * Gets the day-of-month field. * <p> * This method returns the primitive {@code int} value for the day-of-month. * * @return the day-of-month, from 1 to 31 */ public int getDayOfMonth() { return date.getDayOfMonth(); }
/** * Gets the day-of-month field. * <p> * This method returns the primitive {@code int} value for the day-of-month. * * @return the day-of-month, from 1 to 31 */ public int getDayOfMonth() { return date.getDayOfMonth(); }
private long monthsUntil(LocalDate end) { long packed1 = getProlepticMonth() * 32L + getDayOfMonth(); // no overflow long packed2 = end.getProlepticMonth() * 32L + end.getDayOfMonth(); // no overflow return (packed2 - packed1) / 32; }
private long monthsUntil(LocalDate end) { long packed1 = getProlepticMonth() * 32L + getDayOfMonth(); // no overflow long packed2 = end.getProlepticMonth() * 32L + end.getDayOfMonth(); // no overflow return (packed2 - packed1) / 32; }
@Override public int lengthOfYear() { Calendar jcal = Calendar.getInstance(JapaneseChronology.LOCALE); jcal.set(Calendar.ERA, era.getValue() + JapaneseEra.ERA_OFFSET); jcal.set(yearOfEra, isoDate.getMonthValue() - 1, isoDate.getDayOfMonth()); return jcal.getActualMaximum(Calendar.DAY_OF_YEAR); }
@Override public int lengthOfYear() { Calendar jcal = Calendar.getInstance(JapaneseChronology.LOCALE); jcal.set(Calendar.ERA, era.getValue() + JapaneseEra.ERA_OFFSET); jcal.set(yearOfEra, isoDate.getMonthValue() - 1, isoDate.getDayOfMonth()); return jcal.getActualMaximum(Calendar.DAY_OF_YEAR); }
/** * Converts a {@code LocalDate} to a {@code java.sql.Date}. * * @param date the local date, not null * @return the SQL date, not null */ @SuppressWarnings("deprecation") public static java.sql.Date toSqlDate(LocalDate date) { return new java.sql.Date(date.getYear() - 1900, date.getMonthValue() -1, date.getDayOfMonth()); }
/** * Converts a {@code LocalDate} to a {@code java.sql.Date}. * * @param date the local date, not null * @return the SQL date, not null */ @SuppressWarnings("deprecation") public static java.sql.Date toSqlDate(LocalDate date) { return new java.sql.Date(date.getYear() - 1900, date.getMonthValue() -1, date.getDayOfMonth()); }
private ValueRange actualRange(int calendarField) { Calendar jcal = Calendar.getInstance(JapaneseChronology.LOCALE); jcal.set(Calendar.ERA, era.getValue() + JapaneseEra.ERA_OFFSET); jcal.set(yearOfEra, isoDate.getMonthValue() - 1, isoDate.getDayOfMonth()); return ValueRange.of(jcal.getActualMinimum(calendarField), jcal.getActualMaximum(calendarField)); }
private ValueRange actualRange(int calendarField) { Calendar jcal = Calendar.getInstance(JapaneseChronology.LOCALE); jcal.set(Calendar.ERA, era.getValue() + JapaneseEra.ERA_OFFSET); jcal.set(yearOfEra, isoDate.getMonthValue() - 1, isoDate.getDayOfMonth()); return ValueRange.of(jcal.getActualMinimum(calendarField), jcal.getActualMaximum(calendarField)); }
void adjustToFowards(int year) { if (adjustForwards == false && dayOfMonth > 0) { LocalDate adjustedDate = LocalDate.of(year, month, dayOfMonth).minusDays(6); dayOfMonth = adjustedDate.getDayOfMonth(); month = adjustedDate.getMonth(); adjustForwards = true; } } }
void adjustToFowards(int year) { if (adjustForwards == false && dayOfMonth > 0) { LocalDate adjustedDate = LocalDate.of(year, month, dayOfMonth).minusDays(6); dayOfMonth = adjustedDate.getDayOfMonth(); month = adjustedDate.getMonth(); adjustForwards = true; } } }
@Override public com.datastax.driver.core.LocalDate convert(LocalDate source) { return com.datastax.driver.core.LocalDate.fromYearMonthDay(source.getYear(), source.getMonthValue(), source.getDayOfMonth()); } }
/** * Obtains the current month-day from the specified clock. * <p> * This will query the specified clock to obtain the current month-day. * Using this method allows the use of an alternate clock for testing. * The alternate clock may be introduced using {@link Clock dependency injection}. * * @param clock the clock to use, not null * @return the current month-day, not null */ public static MonthDay now(Clock clock) { final LocalDate now = LocalDate.now(clock); // called once return MonthDay.of(now.getMonth(), now.getDayOfMonth()); }
/** * Obtains the current month-day from the specified clock. * <p> * This will query the specified clock to obtain the current month-day. * Using this method allows the use of an alternate clock for testing. * The alternate clock may be introduced using {@link Clock dependency injection}. * * @param clock the clock to use, not null * @return the current month-day, not null */ public static MonthDay now(Clock clock) { final LocalDate now = LocalDate.now(clock); // called once return MonthDay.of(now.getMonth(), now.getDayOfMonth()); }
@Override public void onDateSelected(@NonNull MaterialCalendarView widget, @NonNull CalendarDay calendarDay, boolean selected) { LocalDate localDate = calendarDay.getDate(); WeekFields weekFields = WeekFields.of(Locale.getDefault()); calendarBehavior.setWeekOfMonth(localDate.get(weekFields.weekOfMonth())); if (selected) { dayOfWeek = localDate.getDayOfWeek().getValue(); dayOfMonth = localDate.getDayOfMonth(); } } });