DefaultDateTypeAdapter.DateType and then using its createAdapterFactory methods.Important Note
Instances of this class (or rather the SimpleDateFormat they use)
capture the current default Locale and TimeZone when they are created. Therefore
avoid storing factories obtained from DateType in static fields, since they only
create a single adapter instance and its behavior would then depend on when Gson classes are
loaded first, and which default Locale and TimeZone was used at that point.
| Modifier and Type | Class and Description |
|---|---|
| public abstract static class |
| Modifier and Type | Field and Description |
|---|---|
| private final List | dateFormats
List of 1 or more different date formats used for de-serialization attempts. |
| private final DefaultDateTypeAdapter. | |
| public static final TypeAdapterFactory | DEFAULT_STYLE_FACTORY
Factory for |
| private static final String |
| Access | Constructor and Description |
|---|---|
| private | |
| private |
| Modifier and Type | Method and Description |
|---|---|
| private Date | |
| public T | read(JsonReader in)
Implements abstract com. Reads one JSON value (an array, object, string, number, boolean or null) and converts it to a Java object. |
| public String | |
| public void | write(JsonWriter out, Date value)
Implements abstract com. Writes one JSON value (an array, object, string, number, boolean or null) for |
| dateFormats | back to summary |
|---|---|
| private final List<DateFormat> dateFormats List of 1 or more different date formats used for de-serialization attempts. The first of them is used for serialization as well. | |
| dateType | back to summary |
|---|---|
| private final DefaultDateTypeAdapter. | |
| DEFAULT_STYLE_FACTORY | back to summary |
|---|---|
| public static final TypeAdapterFactory DEFAULT_STYLE_FACTORY Factory for | |
| SIMPLE_NAME | back to summary |
|---|---|
| private static final String SIMPLE_NAME | |
| DefaultDateTypeAdapter | back to summary |
|---|---|
| private DefaultDateTypeAdapter(DefaultDateTypeAdapter. | |
| DefaultDateTypeAdapter | back to summary |
|---|---|
| private DefaultDateTypeAdapter(DefaultDateTypeAdapter. | |
| deserializeToDate | back to summary |
|---|---|
| private Date deserializeToDate(JsonReader in) throws IOException | |
| read | back to summary |
|---|---|
| public T read(JsonReader in) throws IOException Implements abstract com. Doc from com. Reads one JSON value (an array, object, string, number, boolean or null) and converts it to a Java object. Returns the converted object.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non-
| |
| write | back to summary |
|---|---|
| public void write(JsonWriter out, Date value) throws IOException Implements abstract com. Doc from com. Writes one JSON value (an array, object, string, number, boolean or null) for
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final DefaultDateTypeAdapter. | |
| private final Class |
| Modifier and Type | Method and Description |
|---|---|
| public final TypeAdapterFactory | |
| public final TypeAdapterFactory | |
| private TypeAdapterFactory | |
| protected abstract T |
| DATE | back to summary |
|---|---|
| public static final DefaultDateTypeAdapter. | |
| dateClass | back to summary |
|---|---|
| private final Class<T> dateClass | |
| DateType | back to summary |
|---|---|
| protected DateType(Class<T> dateClass) | |
| createAdapterFactory | back to summary |
|---|---|
| public final TypeAdapterFactory createAdapterFactory(String datePattern) | |
| createAdapterFactory | back to summary |
|---|---|
| public final TypeAdapterFactory createAdapterFactory(int dateStyle, int timeStyle) | |
| createFactory | back to summary |
|---|---|
| private TypeAdapterFactory createFactory(DefaultDateTypeAdapter<T> adapter) | |
| deserialize | back to summary |
|---|---|
| protected abstract T deserialize(Date date) | |