Package org.joda.time.convert
Class CalendarConverter
- java.lang.Object
-
- org.joda.time.convert.AbstractConverter
-
- org.joda.time.convert.CalendarConverter
-
- All Implemented Interfaces:
Converter,InstantConverter,PartialConverter
final class CalendarConverter extends AbstractConverter implements InstantConverter, PartialConverter
CalendarConverter converts a java util Calendar to an instant or partial. The Calendar is converted to milliseconds and the chronology that best matches the calendar.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static CalendarConverterINSTANCESingleton instance.
-
Constructor Summary
Constructors Modifier Constructor Description protectedCalendarConverter()Restricted constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ChronologygetChronology(java.lang.Object object, Chronology chrono)Gets the chronology.ChronologygetChronology(java.lang.Object object, DateTimeZone zone)Gets the chronology, which is the GJChronology if a GregorianCalendar is used, BuddhistChronology if a BuddhistCalendar is used or ISOChronology otherwise.longgetInstantMillis(java.lang.Object object, Chronology chrono)Gets the millis, which is the Calendar millis value.java.lang.Class<?>getSupportedType()Returns Calendar.class.-
Methods inherited from class org.joda.time.convert.AbstractConverter
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.PartialConverter
getPartialValues, getPartialValues
-
-
-
-
Field Detail
-
INSTANCE
static final CalendarConverter INSTANCE
Singleton instance.
-
-
Method Detail
-
getChronology
public Chronology getChronology(java.lang.Object object, Chronology chrono)
Gets the chronology.If a chronology is specified then it is used. Otherwise, it is the GJChronology if a GregorianCalendar is used, BuddhistChronology if a BuddhistCalendar is used or ISOChronology otherwise. The time zone is extracted from the calendar if possible, default used if not.
- Specified by:
getChronologyin interfaceInstantConverter- Specified by:
getChronologyin interfacePartialConverter- Overrides:
getChronologyin classAbstractConverter- Parameters:
object- the Calendar to convert, must not be nullchrono- the chronology to use, null means use Calendar- Returns:
- the chronology, never null
- Throws:
java.lang.NullPointerException- if the object is nulljava.lang.ClassCastException- if the object is an invalid type
-
getChronology
public Chronology getChronology(java.lang.Object object, DateTimeZone zone)
Gets the chronology, which is the GJChronology if a GregorianCalendar is used, BuddhistChronology if a BuddhistCalendar is used or ISOChronology otherwise. The time zone specified is used in preference to that on the calendar.- Specified by:
getChronologyin interfaceInstantConverter- Specified by:
getChronologyin interfacePartialConverter- Overrides:
getChronologyin classAbstractConverter- Parameters:
object- the Calendar to convert, must not be nullzone- the specified zone to use, null means default zone- Returns:
- the chronology, never null
- Throws:
java.lang.NullPointerException- if the object is nulljava.lang.ClassCastException- if the object is an invalid type
-
getInstantMillis
public long getInstantMillis(java.lang.Object object, Chronology chrono)Gets the millis, which is the Calendar millis value.- Specified by:
getInstantMillisin interfaceInstantConverter- Overrides:
getInstantMillisin classAbstractConverter- Parameters:
object- the Calendar to convert, must not be nullchrono- the chronology result from getChronology, non-null- Returns:
- the millisecond value
- Throws:
java.lang.NullPointerException- if the object is nulljava.lang.ClassCastException- if the object is an invalid type
-
getSupportedType
public java.lang.Class<?> getSupportedType()
Returns Calendar.class.- Specified by:
getSupportedTypein interfaceConverter- Returns:
- Calendar.class
-
-