mirror of https://github.com/plexusorg/Plex.git
21 lines
621 B
Java
21 lines
621 B
Java
package dev.plex.util.adapter;
|
|
|
|
import com.google.gson.*;
|
|
|
|
import java.lang.reflect.Type;
|
|
import java.time.Instant;
|
|
import java.time.LocalDateTime;
|
|
import java.time.ZoneId;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
public class LocalDateTimeDeserializer implements JsonDeserializer<LocalDateTime>
|
|
{
|
|
|
|
@Override
|
|
public LocalDateTime deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
|
{
|
|
Instant instant = Instant.ofEpochMilli(json.getAsJsonPrimitive().getAsLong());
|
|
return LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
|
|
}
|
|
}
|