@Override public final ValueRange range( TemporalField field ) { return temporal().range( field ); }
@Override public final ValueRange range( TemporalField field ) { return temporal().range( field ); }
@Override public Temporal adjustInto(Temporal temporal) { long adjustedDayOfMonth = Math.min(dayOfMonth, temporal.range(ChronoField.DAY_OF_MONTH).getMaximum()); return temporal.with(ChronoField.DAY_OF_MONTH, adjustedDayOfMonth); } };
@Override public Temporal adjustInto(Temporal temporal) { switch (ordinal) { case 0: return temporal.with(DAY_OF_MONTH, 1); case 1: return temporal.with(DAY_OF_MONTH, temporal.range(DAY_OF_MONTH).getMaximum()); case 2: return temporal.with(DAY_OF_MONTH, 1).plus(1, MONTHS); case 3: return temporal.with(DAY_OF_YEAR, 1); case 4: return temporal.with(DAY_OF_YEAR, temporal.range(DAY_OF_YEAR).getMaximum()); case 5: return temporal.with(DAY_OF_YEAR, 1).plus(1, YEARS); } throw new IllegalStateException("Unreachable"); } }
public static TemporalAdjuster nextDayOfMonth(int dayOfMonth) { validateDayOfMonth(dayOfMonth); return temporal -> { int currentDayOfMonth = temporal.get(DAY_OF_MONTH); if(currentDayOfMonth >= dayOfMonth || temporal.range(DAY_OF_MONTH).getMaximum() == currentDayOfMonth) { temporal = temporal.with(firstDayOfNextMonth()); } ValueRange dayRange = temporal.range(DAY_OF_MONTH); int newDayOfMonth = dayOfMonth; if (dayRange.getMaximum() < dayOfMonth) { newDayOfMonth = (int) dayRange.getMaximum(); } return temporal.with(DAY_OF_MONTH, newDayOfMonth); }; }
public static TemporalAdjuster nextOrSameDayOfMonth(int dayOfMonth) { validateDayOfMonth(dayOfMonth); TemporalAdjuster nextDayOfMonth = nextDayOfMonth(dayOfMonth); return temporal -> { int currentDayOfMonth = temporal.get(DAY_OF_MONTH); if (currentDayOfMonth == dayOfMonth || (currentDayOfMonth < dayOfMonth && currentDayOfMonth == temporal.range(DAY_OF_MONTH).getMaximum())) { return temporal; } return temporal.with(nextDayOfMonth); }; }
return (getYear() <= 0 ? ValueRange.of(1, Year.MAX_VALUE + 1) : ValueRange.of(1, Year.MAX_VALUE)); return Temporal.super.range(field);
return temporal.with(DAY_OF_MONTH, Math.min(temporal.range(DAY_OF_MONTH).getMaximum(), day));
@Override public Temporal adjustInto(Temporal temporal) { if (ordinal >= 0) { Temporal temp = temporal.with(DAY_OF_MONTH, 1); int curDow = temp.get(DAY_OF_WEEK); int dowDiff = (dowValue - curDow + 7) % 7; dowDiff += (ordinal - 1L) * 7L; // safe from overflow return temp.plus(dowDiff, DAYS); } else { Temporal temp = temporal.with(DAY_OF_MONTH, temporal.range(DAY_OF_MONTH).getMaximum()); int curDow = temp.get(DAY_OF_WEEK); int daysDiff = dowValue - curDow; daysDiff = (daysDiff == 0 ? 0 : (daysDiff > 0 ? daysDiff - 7 : daysDiff)); daysDiff -= (-ordinal - 1L) * 7L; // safe from overflow return temp.plus(daysDiff, DAYS); } } }