Interface IDurationItem

All Superinterfaces:
IAnyAtomicItem, IAtomicValuedItem, ICollectionValue, IItem
All Known Subinterfaces:
IDayTimeDurationItem, IYearMonthDurationItem

public interface IDurationItem extends IAnyAtomicItem
An atomic Metapath item representing a duration data value.

This interface supports both day-time and year-month duration formats following the ISO 8601 standard. Examples of valid durations include:

  • P1Y2M (1 year, 2 months)
  • P3DT4H5M (3 days, 4 hours, 5 minutes)
See Also:
  • Method Details

    • type

      @NonNull static IAtomicOrUnionType<IDurationItem> type()
      Get the type information for this item.
      Returns:
      the type information
    • valueOf

      @NonNull static IDurationItem valueOf(@NonNull String value)
      Construct a new duration item using the provided string value.
      Parameters:
      value - a string representing a day time duration
      Returns:
      the new item
      Throws:
      InvalidTypeMetapathException - if the provided string value is not a year/month or day/time duration value according to ISO 8601
    • cast

      @NonNull static IDurationItem cast(@NonNull IAnyAtomicItem item)
      Cast the provided type to this item type.
      Parameters:
      item - the item to cast
      Returns:
      the original item if it is already this type, otherwise a new item cast to this type
      Throws:
      InvalidValueForCastFunctionException - if the provided item cannot be cast to this type
    • getValue

      TemporalAmount getValue()
      Description copied from interface: IAnyAtomicItem
      Get the "wrapped" value represented by this item.
      Specified by:
      getValue in interface IAnyAtomicItem
      Specified by:
      getValue in interface IItem
      Returns:
      the value
    • castAsType

      default IDurationItem castAsType(IAnyAtomicItem item)
      Description copied from interface: IAnyAtomicItem
      Cast the provided item to be the same type as this item.
      Specified by:
      castAsType in interface IAnyAtomicItem
      Parameters:
      item - the item to cast
      Returns:
      an atomic item of this type
    • compareTo

      int compareTo(@NonNull IDurationItem item)
      Compares this value with the argument.
      Parameters:
      item - the item to compare with this value
      Returns:
      a negative integer, zero, or a positive integer if this value is less than, equal to, or greater than the item.