Plex/src/main/java/dev/plex/util/adapter/LocalDateTimeSerializer.java
Telesphoreo 2631867e27 Fix a whole bunch of bugs
- Rewrite how bans are handled
- Add /unfreeze command
- Rename LoginListener to BanListener
- Persistent commandspy
2022-02-06 23:53:57 -06:00

20 lines
643 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.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
public class LocalDateTimeSerializer implements JsonSerializer<LocalDateTime>
{
@Override
public JsonElement serialize(LocalDateTime src, Type typeOfSrc, JsonSerializationContext context)
{
return new JsonPrimitive(src.toInstant(ZoneId.systemDefault().getRules().getOffset(Instant.now())).toEpochMilli());
}
}