mirror of
https://github.com/plexusorg/Plex.git
synced 2024-11-15 08:13:32 +00:00
20 lines
594 B
Java
20 lines
594 B
Java
|
package dev.plex.util.adapter;
|
||
|
|
||
|
import com.google.gson.JsonElement;
|
||
|
import com.google.gson.JsonPrimitive;
|
||
|
import com.google.gson.JsonSerializationContext;
|
||
|
import com.google.gson.JsonSerializer;
|
||
|
|
||
|
import java.lang.reflect.Type;
|
||
|
import java.time.LocalDateTime;
|
||
|
import java.time.format.DateTimeFormatter;
|
||
|
|
||
|
public class LocalDateTimeAdapter implements JsonSerializer<LocalDateTime>
|
||
|
{
|
||
|
@Override
|
||
|
public JsonElement serialize(LocalDateTime src, Type typeOfSrc, JsonSerializationContext context)
|
||
|
{
|
||
|
return new JsonPrimitive(src.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
|
||
|
}
|
||
|
}
|