/** * Determine if this day is before the given instance * * @param other the other day to test * @return true if this is before other, false if equal or after */ public boolean isBefore(@NonNull final CalendarDay other) { return date.isBefore(other.getDate()); }
/** * Clear the previous selection, select the range of days from first to last, and finally * invalidate. First day should be before last day, otherwise the selection won't happen. * * @param first The first day of the range. * @param last The last day in the range. * @see CalendarPagerAdapter#setDateSelected(CalendarDay, boolean) */ public void selectRange(final CalendarDay first, final CalendarDay last) { selectedDates.clear(); // Copy to start from the first day and increment LocalDate temp = LocalDate.of(first.getYear(), first.getMonth(), first.getDay()); // for comparison final LocalDate end = last.getDate(); while( temp.isBefore(end) || temp.equals(end) ) { selectedDates.add(CalendarDay.from(temp)); temp = temp.plusDays(1); } invalidateSelectedDates(); }
/** * Constructs a {@code JapaneseDate}. This constructor does NOT validate the given parameters, * and {@code era} and {@code year} must agree with {@code isoDate}. * * @param era the era, validated not null * @param year the year-of-era, validated * @param isoDate the standard local date, validated not null */ JapaneseDate(JapaneseEra era, int year, LocalDate isoDate) { if (isoDate.isBefore(MIN_DATE)) { throw new DateTimeException("Minimum supported date is January 1st Meiji 6"); } this.era = era; this.yearOfEra = year; this.isoDate = isoDate; }
/** * Constructs a {@code JapaneseDate}. This constructor does NOT validate the given parameters, * and {@code era} and {@code year} must agree with {@code isoDate}. * * @param era the era, validated not null * @param year the year-of-era, validated * @param isoDate the standard local date, validated not null */ JapaneseDate(JapaneseEra era, int year, LocalDate isoDate) { if (isoDate.isBefore(MIN_DATE)) { throw new DateTimeException("Minimum supported date is January 1st Meiji 6"); } this.era = era; this.yearOfEra = year; this.isoDate = isoDate; }
/** * Obtains an instance of {@code JapaneseEra} from a date. * * @param date the date, not null * @return the Era singleton, never null */ static JapaneseEra from(LocalDate date) { if (date.isBefore(MEIJI.since)) { throw new DateTimeException("Date too early: " + date); } JapaneseEra[] known = KNOWN_ERAS.get(); for (int i = known.length - 1; i >= 0; i--) { JapaneseEra era = known[i]; if (date.compareTo(era.since) >= 0) { return era; } } return null; }
/** * Obtains an instance of {@code JapaneseEra} from a date. * * @param date the date, not null * @return the Era singleton, never null */ static JapaneseEra from(LocalDate date) { if (date.isBefore(MEIJI.since)) { throw new DateTimeException("Date too early: " + date); } JapaneseEra[] known = KNOWN_ERAS.get(); for (int i = known.length - 1; i >= 0; i--) { JapaneseEra era = known[i]; if (date.compareTo(era.since) >= 0) { return era; } } return null; }
/** * Creates an instance from an ISO date. * * @param isoDate the standard local date, validated not null */ JapaneseDate(LocalDate isoDate) { if (isoDate.isBefore(MIN_DATE)) { throw new DateTimeException("Minimum supported date is January 1st Meiji 6"); } this.era = JapaneseEra.from(isoDate); int yearOffset = this.era.startDate().getYear() - 1; this.yearOfEra = isoDate.getYear() - yearOffset; this.isoDate = isoDate; }
/** * Creates an instance from an ISO date. * * @param isoDate the standard local date, validated not null */ JapaneseDate(LocalDate isoDate) { if (isoDate.isBefore(MIN_DATE)) { throw new DateTimeException("Minimum supported date is January 1st Meiji 6"); } this.era = JapaneseEra.from(isoDate); int yearOffset = this.era.startDate().getYear() - 1; this.yearOfEra = isoDate.getYear() - yearOffset; this.isoDate = isoDate; }
int yearOffset = eraStartDate.getYear() - 1; LocalDate date = LocalDate.of(yearOfEra + yearOffset, month, dayOfMonth); if (date.isBefore(eraStartDate) || date.isAfter(eraEndDate)) { throw new DateTimeException("Requested date is outside bounds of era " + era);
int yearOffset = eraStartDate.getYear() - 1; LocalDate date = LocalDate.of(yearOfEra + yearOffset, month, dayOfMonth); if (date.isBefore(eraStartDate) || date.isAfter(eraEndDate)) { throw new DateTimeException("Requested date is outside bounds of era " + era);
if (isoDate.isBefore(eraStartDate) || isoDate.isAfter(eraEndDate)) { throw new DateTimeException("Requested date is outside bounds of era " + era);
if (isoDate.isBefore(eraStartDate) || isoDate.isAfter(eraEndDate)) { throw new DateTimeException("Requested date is outside bounds of era " + era);
if (endDate.isAfter(date) && end.time.isBefore(time)) { endDate = endDate.minusDays(1); } else if (endDate.isBefore(date) && end.time.isAfter(time)) { endDate = endDate.plusDays(1);
if (endDate.isAfter(date) && end.time.isBefore(time)) { endDate = endDate.minusDays(1); } else if (endDate.isBefore(date) && end.time.isAfter(time)) { endDate = endDate.plusDays(1);