mirror of
https://github.com/plexusorg/Plex.git
synced 2026-06-04 21:46:55 +00:00
Add Javadocs
This commit is contained in:
@@ -12,16 +12,32 @@ import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
/**
|
||||
* Gson adapter that stores {@link ZonedDateTime} values as epoch milliseconds in UTC.
|
||||
*/
|
||||
public class ZonedDateTimeAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime>
|
||||
{
|
||||
private static final ZoneId UTC = ZoneId.of("Etc/UTC");
|
||||
|
||||
/**
|
||||
* Creates a Gson adapter for {@link ZonedDateTime}.
|
||||
*/
|
||||
public ZonedDateTimeAdapter()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public JsonElement serialize(ZonedDateTime src, Type typeOfSrc, JsonSerializationContext context)
|
||||
{
|
||||
return new JsonPrimitive(src.toInstant().toEpochMilli());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ZonedDateTime deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user