Support customizing date format in model (de)serialization in Java client

and update the default date format to conform to RFC3339
This commit is contained in:
xhh
2015-11-07 15:16:13 +08:00
parent a5878130c4
commit c59be88a3e
6 changed files with 122 additions and 8 deletions

View File

@@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.datatype.joda.*;
import java.text.DateFormat;
import java.io.IOException;
{{>generatedAnnotation}}
@@ -20,6 +22,13 @@ public class JSON {
mapper.registerModule(new JodaModule());
}
/**
* Set the date format for JSON (de)serialization with Date properties.
*/
public void setDateFormat(DateFormat dateFormat) {
mapper.setDateFormat(dateFormat);
}
/**
* Serialize the given Java object into JSON string.
*/