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
FieldsModifier and TypeFieldDescription(package private) static final CalendarConverterSingleton instance. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetChronology(Object object, Chronology chrono) Gets the chronology.getChronology(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(Object object, Chronology chrono) Gets the millis, which is the Calendar millis value.Class<?> Returns Calendar.class.Methods inherited from class org.joda.time.convert.AbstractConverter
getPartialValues, 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.PartialConverter
getPartialValues, getPartialValues
-
Field Details
-
INSTANCE
Singleton instance.
-
-
Constructor Details
-
CalendarConverter
protected CalendarConverter()Restricted constructor.
-
-
Method Details
-
getChronology
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:
NullPointerException- if the object is nullClassCastException- if the object is an invalid type
-
getChronology
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:
NullPointerException- if the object is nullClassCastException- if the object is an invalid type
-
getInstantMillis
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:
NullPointerException- if the object is nullClassCastException- if the object is an invalid type
-
getSupportedType
Returns Calendar.class.- Specified by:
getSupportedTypein interfaceConverter- Returns:
- Calendar.class
-