public class MonthNameConverter extends java.lang.Object implements ObjectConverter
Modifier and Type | Field and Description |
---|---|
static java.text.DateFormat |
CONCISE_FORMAT
0 -> "1", 1 -> "2", ..., 11 -> "12"
|
static ConverterContext |
CONTEXT
Default ConverterContext for MonthConverter.
|
static java.text.DateFormat |
LONG_FORMAT
0 -> "January", 1 -> "February", ..., 11 -> "December"
|
static java.text.DateFormat |
MEDIUM_FORMAT
0 -> "Jan", 1 -> "Feb", ..., 11 -> "Dec"
|
static java.text.DateFormat |
SHORT_FORMAT
0 -> "01", 1 -> "02", ..., 11 -> "12"
|
Constructor and Description |
---|
MonthNameConverter()
Creates a new CalendarConverter.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
fromString(java.lang.String string,
ConverterContext context)
Converts from String to an object.
|
protected java.util.Calendar |
getCalendarByMonth(int month) |
java.text.DateFormat |
getDefaultFormat()
Gets default format to format a month.
|
static void |
main(java.lang.String[] args) |
void |
setDefaultFormat(java.text.DateFormat defaultFormat)
Sets default format to format a month.
|
boolean |
supportFromString(java.lang.String string,
ConverterContext context)
If it supports fromString.
|
boolean |
supportToString(java.lang.Object object,
ConverterContext context)
If it supports toString method.
|
java.lang.String |
toString(java.lang.Object object,
ConverterContext context)
Converts from object to String based on current locale.
|
public static ConverterContext CONTEXT
public static final java.text.DateFormat CONCISE_FORMAT
public static final java.text.DateFormat SHORT_FORMAT
public static final java.text.DateFormat MEDIUM_FORMAT
public static final java.text.DateFormat LONG_FORMAT
public java.lang.String toString(java.lang.Object object, ConverterContext context)
ObjectConverter
toString
in interface ObjectConverter
object
- object to be convertedcontext
- converter context to be usedprotected java.util.Calendar getCalendarByMonth(int month)
public boolean supportToString(java.lang.Object object, ConverterContext context)
ObjectConverter
supportToString
in interface ObjectConverter
object
- object to be convertedcontext
- converter context to be usedpublic java.lang.Object fromString(java.lang.String string, ConverterContext context)
ObjectConverter
fromString
in interface ObjectConverter
string
- the stringcontext
- context to be convertedpublic boolean supportFromString(java.lang.String string, ConverterContext context)
ObjectConverter
supportFromString
in interface ObjectConverter
string
- the stringcontext
- context to be convertedpublic java.text.DateFormat getDefaultFormat()
public void setDefaultFormat(java.text.DateFormat defaultFormat)
MEDIUM_FORMAT
.defaultFormat
- the default format to format the month.public static void main(java.lang.String[] args)