Package org.joda.time.convert
Class StringConverter
java.lang.Object
org.joda.time.convert.AbstractConverter
org.joda.time.convert.StringConverter
- All Implemented Interfaces:
Converter,DurationConverter,InstantConverter,IntervalConverter,PartialConverter,PeriodConverter
class StringConverter
extends AbstractConverter
implements InstantConverter, PartialConverter, DurationConverter, PeriodConverter, IntervalConverter
StringConverter converts from a String to an instant, partial,
duration, period or interval..
- Since:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final StringConverterSingleton instance. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlonggetDurationMillis(Object object) Gets the duration of the string using the standard type.longgetInstantMillis(Object object, Chronology chrono) Gets the millis, which is the ISO parsed string value.int[]getPartialValues(ReadablePartial fieldSource, Object object, Chronology chrono, DateTimeFormatter parser) Extracts the values of the partial from an object of this converter's type.Class<?> Returns String.class.voidsetInto(ReadWritableInterval writableInterval, Object object, Chronology chrono) Sets the value of the mutable interval from the string.voidsetInto(ReadWritablePeriod period, 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, getPartialValues, getPeriodType, isReadableInterval, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.joda.time.convert.InstantConverter
getChronology, getChronologyMethods inherited from interface org.joda.time.convert.IntervalConverter
isReadableIntervalMethods inherited from interface org.joda.time.convert.PartialConverter
getChronology, getChronology, getPartialValuesMethods inherited from interface org.joda.time.convert.PeriodConverter
getPeriodType
-
Field Details
-
INSTANCE
Singleton instance.
-
-
Constructor Details
-
StringConverter
protected StringConverter()Restricted constructor.
-
-
Method Details
-
getInstantMillis
Gets the millis, which is the ISO parsed string value.- Specified by:
getInstantMillisin interfaceInstantConverter- Overrides:
getInstantMillisin classAbstractConverter- Parameters:
object- the String to convert, must not be nullchrono- the chronology to use, non-null result of getChronology- Returns:
- the millisecond value
- Throws:
IllegalArgumentException- if the value if invalid
-
getPartialValues
public int[] getPartialValues(ReadablePartial fieldSource, Object object, Chronology chrono, DateTimeFormatter parser) Extracts the values of the partial from an object of this converter's type. This method checks if the parser has a zone, and uses it if present. This is most useful for parsing local times with UTC.- Specified by:
getPartialValuesin interfacePartialConverter- Overrides:
getPartialValuesin classAbstractConverter- Parameters:
fieldSource- a partial that provides access to the fields. This partial may be incomplete and only getFieldType(int) should be usedobject- the object to convertchrono- the chronology to use, which is the non-null result of getChronology()parser- the parser to use, may be null- Returns:
- the array of field values that match the fieldSource, must be non-null valid
- Throws:
ClassCastException- if the object is invalidIllegalArgumentException- if the value if invalid- Since:
- 1.3
-
getDurationMillis
Gets the duration of the string using the standard type. This matches the toString() method of ReadableDuration.- Specified by:
getDurationMillisin interfaceDurationConverter- Parameters:
object- the String to convert, must not be null- Returns:
- the millisecond duration
- Throws:
ClassCastException- if the object is invalid
-
setInto
Extracts duration values from an object of this converter's type, and sets them into the given ReadWritableDuration.- Specified by:
setIntoin interfacePeriodConverter- Parameters:
period- period to get modifiedobject- the String to convert, must not be nullchrono- the chronology to use- Throws:
ClassCastException- if the object is invalid
-
setInto
Sets the value of the mutable interval from the string.- Specified by:
setIntoin interfaceIntervalConverter- Parameters:
writableInterval- the interval to setobject- the String to convert, must not be nullchrono- the chronology to use, may be null
-
getSupportedType
Returns String.class.- Specified by:
getSupportedTypein interfaceConverter- Returns:
- String.class
-