public class DateAsTimeSinceEpochTypeAdapter extends Object implements JsonSerializer<Date>, JsonDeserializer<Date>
Date instances in JSON objects to or from timestamps since the epoch.| Constructor and Description |
|---|
DateAsTimeSinceEpochTypeAdapter(TimeUnit timeUnit)
Constructs a new date/timestamp type adapter that uses the given time unit to measure time since the epoch.
|
| Modifier and Type | Method and Description |
|---|---|
Date |
deserialize(JsonElement json,
Type typeOfT,
JsonDeserializationContext context) |
JsonElement |
serialize(Date src,
Type typeOfSrc,
JsonSerializationContext context) |
public DateAsTimeSinceEpochTypeAdapter(TimeUnit timeUnit)
timeUnit - the time unit in which to express timestampspublic Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
deserialize in interface JsonDeserializer<Date>JsonParseExceptionpublic JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context)
serialize in interface JsonSerializer<Date>Copyright © 2013–2018 Turo. All rights reserved.