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
FieldsModifier and TypeFieldDescription(package private) static final ReadableIntervalConverterSingleton instance. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlonggetDurationMillis(Object object) Gets the millisecond length of the interval.Class<?> Returns ReadableInterval.class.booleanisReadableInterval(Object object, Chronology chrono) Checks if the input is a ReadableInterval.voidsetInto(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.voidsetInto(ReadWritablePeriod writablePeriod, 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, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.joda.time.convert.PeriodConverter
getPeriodType
-
Field Details
-
INSTANCE
Singleton instance.
-
-
Constructor Details
-
ReadableIntervalConverter
protected ReadableIntervalConverter()Restricted constructor.
-
-
Method Details
-
getDurationMillis
Gets the millisecond length of the interval.- Specified by:
getDurationMillisin interfaceDurationConverter- Parameters:
object- the interval- Returns:
- the millisecond duration
-
setInto
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
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:
ClassCastException- if the object is invalid
-
setInto
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:
ClassCastException- if the object is invalid
-
getSupportedType
Returns ReadableInterval.class.- Specified by:
getSupportedTypein interfaceConverter- Returns:
- the object type that this converter supports
-