Package com.eatthepath.pushy.apns.util
Class DateAsTimeSinceEpochTypeAdapter
- java.lang.Object
-
- com.eatthepath.pushy.apns.util.DateAsTimeSinceEpochTypeAdapter
-
- All Implemented Interfaces:
JsonDeserializer<Date>,JsonSerializer<Date>
public class DateAsTimeSinceEpochTypeAdapter extends Object implements JsonSerializer<Date>, JsonDeserializer<Date>
ConvertsDateinstances in JSON objects to or from timestamps since the epoch.- Author:
- Jon Chambers
-
-
Constructor Summary
Constructors Constructor Description DateAsTimeSinceEpochTypeAdapter(TimeUnit timeUnit)Constructs a new date/timestamp type adapter that uses the given time unit to measure time since the epoch.
-
Method Summary
Modifier and Type Method Description Datedeserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)JsonElementserialize(Date src, Type typeOfSrc, JsonSerializationContext context)
-
-
-
Constructor Detail
-
DateAsTimeSinceEpochTypeAdapter
public DateAsTimeSinceEpochTypeAdapter(TimeUnit timeUnit)
Constructs a new date/timestamp type adapter that uses the given time unit to measure time since the epoch.- Parameters:
timeUnit- the time unit in which to express timestamps
-
-
Method Detail
-
deserialize
public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
- Specified by:
deserializein interfaceJsonDeserializer<Date>- Throws:
JsonParseException
-
serialize
public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context)
- Specified by:
serializein interfaceJsonSerializer<Date>
-
-