|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object flexjson.factories.DateObjectFactory
public class DateObjectFactory
DateObjectFactory instantiates java.lang.Date using a list of known java.text.DateFormat instances for json string types, or milliseconds from Jan 1, 1970 GMT for json numeric types. By default it uses the following patterns to recognize dates from json strings: DateFormat.getDateTimeInstance() DateFormat.getDateTimeInstance( DateFormat.LONG, DateFormat.LONG ) DateFormat.getDateTimeInstance( DateFormat.MEDIUM, DateFormat.MEDIUM ) DateFormat.getDateTimeInstance( DateFormat.SHORT, DateFormat.SHORT ) EEE MMM d hh:mm:ss a z yyyy EEE MMM d HH:mm:ss z yyyy MM/dd/yy hh:mm:ss a MM/dd/yy
Field Summary | |
---|---|
protected List<String> |
dateFormats
|
protected ThreadLocal<List<DateFormat>> |
dateFormatters
|
protected boolean |
fromDefaults
|
Constructor Summary | |
---|---|
DateObjectFactory()
This constructor constructs a DateObjectFactory using the default formats known to all instances of the DateObjectFactory. |
|
DateObjectFactory(List<String> dateFormats)
This constructs a DateObjectFactory that only knows how to recognize the given DateFormat instances. |
Method Summary | |
---|---|
DateObjectFactory |
add(String... formats)
Add a new DateFormat to the known formats this instance will recognise. |
static void |
addDefaultFormat(String... formats)
This method adds a default format for all DateObjectFactory. |
protected List<DateFormat> |
getDateFormats()
|
Object |
instantiate(ObjectBinder context,
Object value,
Type targetType,
Class targetClass)
This is a method is used by Flexjson deserialization process to instantiate and bind all data into a Date instance. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected List<String> dateFormats
protected boolean fromDefaults
protected ThreadLocal<List<DateFormat>> dateFormatters
Constructor Detail |
---|
public DateObjectFactory()
public DateObjectFactory(List<String> dateFormats)
dateFormats
- a list of the date formats you want to recognize.Method Detail |
---|
public static void addDefaultFormat(String... formats)
formats
- one or more date formats to add to the known default formats. All formats must conform to the SimpleDateFormat syntax.public DateObjectFactory add(String... formats)
formats
- one or more DateFormat instances to add to the list of
known formats.
public Object instantiate(ObjectBinder context, Object value, Type targetType, Class targetClass)
instantiate
in interface ObjectFactory
context
- the object binding context to keep track of where we are in the object graph
and used for binding into objects.value
- This is the value from the json object at the current path.targetType
- This is the type pulled from the object introspector. Used for Collections and generic types.targetClass
- concrete class pulled from the configuration of the deserializer.
protected List<DateFormat> getDateFormats()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |