Package org.joda.time.convert
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 Summary
Fields Modifier and Type Field Description (package private) static ReadableIntervalConverterINSTANCESingleton instance.
-
Constructor Summary
Constructors Modifier Constructor Description protectedReadableIntervalConverter()Restricted constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetDurationMillis(java.lang.Object object)Gets the millisecond length of the interval.java.lang.Class<?>getSupportedType()Returns ReadableInterval.class.booleanisReadableInterval(java.lang.Object object, Chronology chrono)Checks if the input is a ReadableInterval.voidsetInto(ReadWritableInterval writableInterval, java.lang.Object object, Chronology chrono)Extracts interval endpoint values from an object of this converter's type, and sets them into the given ReadWritableInterval.voidsetInto(ReadWritablePeriod writablePeriod, java.lang.Object object, Chronology chrono)Sets the values of the mutable duration from the specified interval.-
Methods inherited from class org.joda.time.convert.AbstractConverter
getChronology, getChronology, getInstantMillis, getPartialValues, getPartialValues, getPeriodType, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.joda.time.convert.PeriodConverter
getPeriodType
-
-
-
-
Field Detail
-
INSTANCE
static final ReadableIntervalConverter INSTANCE
Singleton instance.
-
-
Method Detail
-
getDurationMillis
public long getDurationMillis(java.lang.Object object)
Gets the millisecond length of the interval.- Specified by:
getDurationMillisin interfaceDurationConverter- Parameters:
object- the interval- Returns:
- the millisecond duration
-
setInto
public void setInto(ReadWritablePeriod writablePeriod, java.lang.Object object, Chronology chrono)
Sets the values of the mutable duration from the specified interval.- Specified by:
setIntoin interfacePeriodConverter- Parameters:
writablePeriod- the period to modifyobject- the interval to set fromchrono- the chronology to use
-
isReadableInterval
public boolean isReadableInterval(java.lang.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:
isReadableIntervalin interfaceIntervalConverter- Overrides:
isReadableIntervalin classAbstractConverter- Parameters:
object- the object to convert, must not be nullchrono- the chronology to use, may be null- Returns:
- true if the input is a ReadableInterval
- Throws:
java.lang.ClassCastException- if the object is invalid
-
setInto
public void setInto(ReadWritableInterval writableInterval, java.lang.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:
setIntoin interfaceIntervalConverter- Parameters:
writableInterval- interval to get modified, not nullobject- the object to convert, must not be nullchrono- the chronology to use, may be null- Throws:
java.lang.ClassCastException- if the object is invalid
-
getSupportedType
public java.lang.Class<?> getSupportedType()
Returns ReadableInterval.class.- Specified by:
getSupportedTypein interfaceConverter- Returns:
- the object type that this converter supports
-
-