Class ReadableIntervalConverter

java.lang.Object
org.joda.time.convert.AbstractConverter
org.joda.time.convert.ReadableIntervalConverter
All Implemented Interfaces:
Converter, DurationConverter, IntervalConverter, PeriodConverter

class ReadableIntervalConverter extends AbstractConverter implements IntervalConverter, DurationConverter, PeriodConverter
Converts intervals into durations of any requested period type.
Since:
1.0
  • Field Details

  • Constructor Details

    • ReadableIntervalConverter

      protected ReadableIntervalConverter()
      Restricted constructor.
  • Method Details

    • getDurationMillis

      public long getDurationMillis(Object object)
      Gets the millisecond length of the interval.
      Specified by:
      getDurationMillis in interface DurationConverter
      Parameters:
      object - the interval
      Returns:
      the millisecond duration
    • setInto

      public void setInto(ReadWritablePeriod writablePeriod, Object object, Chronology chrono)
      Sets the values of the mutable duration from the specified interval.
      Specified by:
      setInto in interface PeriodConverter
      Parameters:
      writablePeriod - the period to modify
      object - the interval to set from
      chrono - the chronology to use
    • isReadableInterval

      public boolean isReadableInterval(Object object, Chronology chrono)
      Checks if the input is a ReadableInterval.

      If it is, then the calling code should cast and copy the fields directly.

      Specified by:
      isReadableInterval in interface IntervalConverter
      Overrides:
      isReadableInterval in class AbstractConverter
      Parameters:
      object - the object to convert, must not be null
      chrono - the chronology to use, may be null
      Returns:
      true if the input is a ReadableInterval
      Throws:
      ClassCastException - if the object is invalid
    • setInto

      public void setInto(ReadWritableInterval writableInterval, Object object, Chronology chrono)
      Extracts interval endpoint values from an object of this converter's type, and sets them into the given ReadWritableInterval.
      Specified by:
      setInto in interface IntervalConverter
      Parameters:
      writableInterval - interval to get modified, not null
      object - the object to convert, must not be null
      chrono - the chronology to use, may be null
      Throws:
      ClassCastException - if the object is invalid
    • getSupportedType

      public Class<?> getSupportedType()
      Returns ReadableInterval.class.
      Specified by:
      getSupportedType in interface Converter
      Returns:
      the object type that this converter supports