Package org.joda.time.convert
Class AbstractConverter
- java.lang.Object
-
- org.joda.time.convert.AbstractConverter
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Chronology
getChronology(java.lang.Object object, Chronology chrono)
Extracts the chronology from an object of this converter's type where the chronology is specified.Chronology
getChronology(java.lang.Object object, DateTimeZone zone)
Extracts the chronology from an object of this converter's type where the time zone is specified.long
getInstantMillis(java.lang.Object object, Chronology chrono)
Extracts the millis from an object of this converter's type.int[]
getPartialValues(ReadablePartial fieldSource, java.lang.Object object, Chronology chrono)
Extracts the values of the partial from an object of this converter's type.int[]
getPartialValues(ReadablePartial fieldSource, java.lang.Object object, Chronology chrono, DateTimeFormatter parser)
Extracts the values of the partial from an object of this converter's type.PeriodType
getPeriodType(java.lang.Object object)
Selects a suitable period type for the given object.boolean
isReadableInterval(java.lang.Object object, Chronology chrono)
Checks if the input is a ReadableInterval.java.lang.String
toString()
Gets a debugging string version of this converter.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.joda.time.convert.Converter
getSupportedType
-
-
-
-
Method Detail
-
getInstantMillis
public long getInstantMillis(java.lang.Object object, Chronology chrono)
Extracts the millis from an object of this converter's type.This implementation returns the current time.
- Parameters:
object
- the object to convertchrono
- the chronology to use, which is always non-null- Returns:
- the millisecond value
-
getChronology
public Chronology getChronology(java.lang.Object object, DateTimeZone zone)
Extracts the chronology from an object of this converter's type where the time zone is specified.This implementation returns the ISO chronology.
- Parameters:
object
- the object to convertzone
- the specified zone to use, null means default zone- Returns:
- the chronology, never null
-
getChronology
public Chronology getChronology(java.lang.Object object, Chronology chrono)
Extracts the chronology from an object of this converter's type where the chronology is specified.This implementation returns the chronology specified, or the ISO chronology in the default zone if null passed in.
- Parameters:
object
- the object to convertchrono
- the chronology to use, null means ISO default- Returns:
- the chronology, never null
-
getPartialValues
public int[] getPartialValues(ReadablePartial fieldSource, java.lang.Object object, Chronology chrono)
Extracts the values of the partial from an object of this converter's type. The chrono parameter is a hint to the converter, should it require a chronology to aid in conversion.This implementation calls
getInstantMillis(Object, Chronology)
.- 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()- Returns:
- the array of field values that match the fieldSource, must be non-null valid
- Throws:
java.lang.ClassCastException
- if the object is invalid
-
getPartialValues
public int[] getPartialValues(ReadablePartial fieldSource, java.lang.Object object, Chronology chrono, DateTimeFormatter parser)
Extracts the values of the partial from an object of this converter's type. The chrono parameter is a hint to the converter, should it require a chronology to aid in conversion.This implementation calls
getPartialValues(ReadablePartial, Object, Chronology)
.- 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
- if converting from a String, the given parser is preferred- Returns:
- the array of field values that match the fieldSource, must be non-null valid
- Throws:
java.lang.ClassCastException
- if the object is invalid- Since:
- 1.3
-
getPeriodType
public PeriodType getPeriodType(java.lang.Object object)
Selects a suitable period type for the given object.- Parameters:
object
- the object to examine- Returns:
- the period type, never null
-
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.
- Parameters:
object
- the object to convertchrono
- the chronology to use, may be null- Returns:
- true if the input is a ReadableInterval
-
toString
public java.lang.String toString()
Gets a debugging string version of this converter.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a debugging string
-
-