Package net.time4j

Interface AdjustableElement<V,​T>

Type Parameters:
V - generic type of element values
T - generic type of target entity an operator is applied to
All Superinterfaces:
ChronoElement<V>, Comparator<ChronoDisplay>, ZonalElement<V>
All Known Subinterfaces:
NavigableElement<V>, OrdinalWeekdayElement, ProportionalElement<V,​T>

public interface AdjustableElement<V,​T> extends ZonalElement<V>

Extends a chronological element by some standard ways of manipulation.

Author:
Meno Hochschild
  • Method Details

    • newValue

      ElementOperator<T> newValue(V value)

      Sets any local entity to given new value of this element.

      Parameters:
      value - new element value
      Returns:
      operator directly applicable also on PlainTimestamp
      Since:
      2.0
      See Also:
      ChronoEntity.with(ChronoElement, V)
    • minimized

      ElementOperator<T> minimized()

      Sets any local entity to the minimum of this element.

      Returns:
      operator directly applicable also on PlainTimestamp
    • maximized

      ElementOperator<T> maximized()

      Sets any local entity to the maximum of this element.

      Returns:
      operator directly applicable also on PlainTimestamp
    • decremented

      ElementOperator<T> decremented()

      Adjusts any local entity such that this element gets the previous value.

      The operator throws a ChronoException if there is no base unit available for this element.

      Returns:
      operator directly applicable also on PlainTimestamp and requiring a base unit in given chronology for decrementing
      See Also:
      TimeAxis.getBaseUnit(ChronoElement)
    • incremented

      ElementOperator<T> incremented()

      Adjusts any local entity such that this element gets the next value.

      The operator throws a ChronoException if there is no base unit available for this element.

      Returns:
      operator directly applicable also on PlainTimestamp and requiring a base unit in given chronology for incrementing
      See Also:
      TimeAxis.getBaseUnit(ChronoElement)
    • atFloor

      ElementOperator<T> atFloor()

      Rounds down an entity by setting all child elements to minimum.

      Many elements are organized by parent-child-relations. The most important dependency chain is: YEAR -> MONTH -> DAY_OF_MONTH -> HOUR_OF_DAY -> MINUTE -> SECOND -> NANO_OF_SECOND. If there is no child element then this operator will not do anything (no-op). Example:

           PlainDate date = PlainDate.of(2016, 11, 24);
           // DAY_OF_WEEK has no time element as child in context of plain calendar dates
           System.out.println(date.with(DAY_OF_WEEK.atFloor())); // 2016-11-24
      
           PlainTimestamp tsp = date.atTime(20, 45);
           // DAY_OF_WEEK has now child elements which can be set to zero
           System.out.println(tsp.with(DAY_OF_WEEK.atFloor())); // 2016-11-24T00
       
      Returns:
      operator directly applicable on local types without timezone
    • atCeiling

      ElementOperator<T> atCeiling()

      Rounds up an entity by setting all child elements to maximum.

      Many elements are organized by parent-child-relations. The most important dependency chain is: YEAR -> MONTH -> DAY_OF_MONTH -> HOUR_OF_DAY -> MINUTE -> SECOND -> NANO_OF_SECOND. If there is no child element then this operator will not do anything (no-op). Example:

           PlainDate date = PlainDate.of(2016, 11, 24);
           // DAY_OF_WEEK has no time element as child in context of plain calendar dates
           System.out.println(date.with(DAY_OF_WEEK.atCeiling())); // 2016-11-24
      
           PlainTimestamp tsp = date.atTime(20, 45);
           // DAY_OF_WEEK has now child elements which can be all maximized
           System.out.println(tsp.with(DAY_OF_WEEK.atCeiling())); // 2016-11-24T23:59:59,999999999
       
      Returns:
      operator directly applicable on local types without timezone
    • atFloor

      default ChronoOperator<T> atFloor(V value)

      Combines newValue(V) and then atFloor().

      Example:

           PlainTime time = PlainTime.nowInSystemTime();
           assertThat(
             time.with(PlainTime.DIGITAL_HOUR_OF_DAY.atFloor(7)),
             is(PlainTime.of(7, 0)));
       
      Parameters:
      value - new element value
      Returns:
      combined operator
      Since:
      4.33
      See Also:
      ChronoEntity.with(ChronoElement, V), newValue(V), atFloor()
    • atCeiling

      default ChronoOperator<T> atCeiling(V value)

      Combines newValue(V) and then atCeiling().

      Parameters:
      value - new element value
      Returns:
      combined operator
      Since:
      4.33
      See Also:
      ChronoEntity.with(ChronoElement, V), newValue(V), atCeiling()