public class DateConverter extends Object implements ObjectConverter
Modifier and Type | Field and Description |
---|---|
static ConverterContext |
DATE_CONTEXT |
static ConverterContext |
DATETIME_CONTEXT |
static ConverterContext |
TIME_CONTEXT |
Constructor and Description |
---|
DateConverter()
Creates a DateConverter.
|
Modifier and Type | Method and Description |
---|---|
Object |
fromString(String string,
ConverterContext context)
Converts from a String to a Date.
|
DateFormat |
getDefaultDatetimeFormat()
Gets DefaultDatetimeFormat to format an calendar.
|
DateFormat |
getDefaultFormat()
Gets DefaultFormat to format an calendar.
|
DateFormat |
getDefaultTimeFormat()
Gets DefaultTimeFormat to format an calendar.
|
void |
setDefaultDatetimeFormat(DateFormat defaultDatetimeFormat)
Sets DefaultDatetimeFormat to format an calendar.
|
void |
setDefaultFormat(DateFormat defaultFormat)
Sets DefaultFormat to format an calendar.
|
void |
setDefaultTimeFormat(DateFormat defaultTimeFormat)
Sets DefaultTimeFormat to format an calendar.
|
boolean |
supportFromString(String string,
ConverterContext context)
If it supports fromString.
|
boolean |
supportToString(Object object,
ConverterContext context)
If it supports toString method.
|
String |
toString(Object object,
ConverterContext context)
Converts the object to String.
|
public static final ConverterContext DATETIME_CONTEXT
public static final ConverterContext TIME_CONTEXT
public static final ConverterContext DATE_CONTEXT
public String toString(Object object, ConverterContext context)
toString
in interface ObjectConverter
object
- the object to be convertedcontext
- the converter context.public boolean supportToString(Object object, ConverterContext context)
ObjectConverter
supportToString
in interface ObjectConverter
object
- object to be convertedcontext
- converter context to be usedpublic Object fromString(String string, ConverterContext context)
fromString
in interface ObjectConverter
string
- the string to be converted.context
- the context. It could be DATETIME_CONTEXT, DATE_CONTEXT or TIME_CONTEXT.public boolean supportFromString(String string, ConverterContext context)
ObjectConverter
supportFromString
in interface ObjectConverter
string
- the stringcontext
- context to be convertedpublic DateFormat getDefaultFormat()
public void setDefaultFormat(DateFormat defaultFormat)
defaultFormat
- the new default date formatpublic DateFormat getDefaultTimeFormat()
TIME_CONTEXT
.public void setDefaultTimeFormat(DateFormat defaultTimeFormat)
TIME_CONTEXT
.defaultTimeFormat
- the new default time formatpublic DateFormat getDefaultDatetimeFormat()
DATETIME_CONTEXT
.public void setDefaultDatetimeFormat(DateFormat defaultDatetimeFormat)
DATETIME_CONTEXT
.defaultDatetimeFormat
- the new defaultdatetime format