Package org.joda.time.convert
Class ReadableDurationConverter
- java.lang.Object
-
- org.joda.time.convert.AbstractConverter
-
- org.joda.time.convert.ReadableDurationConverter
-
- All Implemented Interfaces:
Converter
,DurationConverter
,PeriodConverter
class ReadableDurationConverter extends AbstractConverter implements DurationConverter, PeriodConverter
ReadableDurationConverter extracts milliseconds and chronology from a ReadableDuration.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static ReadableDurationConverter
INSTANCE
Singleton instance.
-
Constructor Summary
Constructors Modifier Constructor Description protected
ReadableDurationConverter()
Restricted constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getDurationMillis(java.lang.Object object)
Extracts the millis from an object of this converter's type.java.lang.Class<?>
getSupportedType()
Returns ReadableDuration.class.void
setInto(ReadWritablePeriod writablePeriod, java.lang.Object object, Chronology chrono)
Extracts duration values from an object of this converter's type, and sets them into the given ReadWritableDuration.-
Methods inherited from class org.joda.time.convert.AbstractConverter
getChronology, getChronology, getInstantMillis, getPartialValues, getPartialValues, getPeriodType, isReadableInterval, 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 ReadableDurationConverter INSTANCE
Singleton instance.
-
-
Method Detail
-
getDurationMillis
public long getDurationMillis(java.lang.Object object)
Extracts the millis from an object of this converter's type.- Specified by:
getDurationMillis
in interfaceDurationConverter
- Parameters:
object
- the object to convert, must not be null- Returns:
- the millisecond value
- Throws:
java.lang.NullPointerException
- if the object is nulljava.lang.ClassCastException
- if the object is an invalid typejava.lang.IllegalArgumentException
- if the object is invalid
-
setInto
public void setInto(ReadWritablePeriod writablePeriod, java.lang.Object object, Chronology chrono)
Extracts duration values from an object of this converter's type, and sets them into the given ReadWritableDuration.- Specified by:
setInto
in interfacePeriodConverter
- Parameters:
writablePeriod
- period to get modifiedobject
- the object to convert, must not be nullchrono
- the chronology to use, must not be null- Throws:
java.lang.NullPointerException
- if the duration or object is nulljava.lang.ClassCastException
- if the object is an invalid typejava.lang.IllegalArgumentException
- if the object is invalid
-
getSupportedType
public java.lang.Class<?> getSupportedType()
Returns ReadableDuration.class.- Specified by:
getSupportedType
in interfaceConverter
- Returns:
- ReadableDuration.class
-
-