Package net.time4j

Interface NavigableElement<V extends Enum<V>>

Type Parameters:
V - generic enum type of element values
All Superinterfaces:
AdjustableElement<V,​PlainDate>, ChronoElement<V>, Comparator<ChronoDisplay>, ZonalElement<V>

public interface NavigableElement<V extends Enum<V>> extends AdjustableElement<V,​PlainDate>

Defines additional enum-based operators for setting new element values taking into account the old element value.

Author:
Meno Hochschild
  • Method Details

    • setToNext

      ElementOperator<PlainDate> setToNext(V value)

      Moves a time point to the first given element value which is after the current element value.

      Example for a date which shall be moved to a special weekday:

        import static net.time4j.Month.MARCH;
        import static net.time4j.PlainDate.DAY_OF_WEEK;
        import static net.time4j.Weekday.MONDAY;
      
        PlainDate date = PlainDate.of(2013, MARCH, 7); // Thursday
        System.out.println(date.with(DAY_OF_WEEK.setToNext(MONDAY)));
        // output: 2013-03-11 (first monday after march 7th)
       
      Parameters:
      value - new element value which is after current value
      Returns:
      operator directly applicable also on PlainTimestamp
    • setToPrevious

      ElementOperator<PlainDate> setToPrevious(V value)

      Moves a time point to the first given element value which is before the current element value.

      Example for a date which shall be moved to a special weekday:

        import static net.time4j.IsoElement.DAY_OF_WEEK;
        import static net.time4j.Month.MARCH;
        import static net.time4j.Weekday.THURSDAY;
      
        PlainDate date = PlainDate.of(2013, MARCH, 7); // Thursday
        System.out.println(date.with(DAY_OF_WEEK.setToPrevious(THURSDAY)));
        // output: 2013-02-28 (Thursday one week earlier)
       
      Parameters:
      value - new element value which is before current value
      Returns:
      operator directly applicable also on PlainTimestamp
    • setToNextOrSame

      ElementOperator<PlainDate> setToNextOrSame(V value)

      Moves a time point to the first given element value which is after or equal to the current element value.

      Is the current element value equal to the given element value then there is no movement.

      Parameters:
      value - new element value which is either after current value or the same
      Returns:
      operator directly applicable also on PlainTimestamp
    • setToPreviousOrSame

      ElementOperator<PlainDate> setToPreviousOrSame(V value)

      Moves a time point to the first given element value which is before or equal to the current element value.

      Is the current element value equal to the given element value then there is no movement.

      Parameters:
      value - new element value which is either before current value or the same
      Returns:
      operator directly applicable also on PlainTimestamp