Package com.jidesoft.converter
Class CalendarConverter
- java.lang.Object
-
- com.jidesoft.converter.DateConverter
-
- com.jidesoft.converter.CalendarConverter
-
- All Implemented Interfaces:
ObjectConverter
public class CalendarConverter extends DateConverter
Converter which converts Calendar to String and converts it back.
-
-
Field Summary
-
Fields inherited from class com.jidesoft.converter.DateConverter
DATE_CONTEXT, DATETIME_CONTEXT, TIME_CONTEXT
-
-
Constructor Summary
Constructors Constructor Description CalendarConverter()
Creates a new CalendarConverter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
fromString(java.lang.String string, ConverterContext context)
Converts from a String to a Calendar.java.lang.String
toString(java.lang.Object object, ConverterContext context)
Converts the object to String.-
Methods inherited from class com.jidesoft.converter.DateConverter
getDefaultDatetimeFormat, getDefaultFormat, getDefaultTimeFormat, setDefaultDatetimeFormat, setDefaultFormat, setDefaultTimeFormat, supportFromString, supportToString
-
-
-
-
Method Detail
-
toString
public java.lang.String toString(java.lang.Object object, ConverterContext context)
Description copied from class:DateConverter
Converts the object to String. The object can be a Calendar, a Date or a Number. As long as the DateFormat can format it correctly, it will be converted to a String. If the object is already a String, we will return it directly as it is.- Specified by:
toString
in interfaceObjectConverter
- Overrides:
toString
in classDateConverter
- Parameters:
object
- the object to be convertedcontext
- the converter context.- Returns:
- the string
-
fromString
public java.lang.Object fromString(java.lang.String string, ConverterContext context)
Converts from a String to a Calendar.- Specified by:
fromString
in interfaceObjectConverter
- Overrides:
fromString
in classDateConverter
- Parameters:
string
- the string to be converted.context
- the context. It could be DATETIME_CONTEXT, DATE_CONTEXT or TIME_CONTEXT.- Returns:
- the Calendar object. If the string is null or empty, null will be returned. If the string cannot be parsed as a date, the string itself will be returned.
-
-