mirror of
https://github.com/plexusorg/Plex.git
synced 2026-06-03 21:16:55 +00:00
Expose ZDT to the API
This commit is contained in:
@@ -6,6 +6,7 @@ plugins {
|
||||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:26.1.2.build.+")
|
||||
compileOnly("org.apache.logging.log4j:log4j-api:2.26.0")
|
||||
compileOnly("com.google.code.gson:gson:2.13.2")
|
||||
compileOnly("org.jetbrains:annotations:26.1.0")
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -7,8 +7,6 @@ import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import dev.plex.util.TimeUtils;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
@@ -16,7 +14,7 @@ import java.time.ZonedDateTime;
|
||||
|
||||
public class ZonedDateTimeAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime>
|
||||
{
|
||||
private static final String TIMEZONE = TimeUtils.TIMEZONE;
|
||||
private static final ZoneId UTC = ZoneId.of("Etc/UTC");
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(ZonedDateTime src, Type typeOfSrc, JsonSerializationContext context)
|
||||
@@ -28,6 +26,6 @@ public class ZonedDateTimeAdapter implements JsonSerializer<ZonedDateTime>, Json
|
||||
public ZonedDateTime deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
||||
{
|
||||
Instant instant = Instant.ofEpochMilli(json.getAsJsonPrimitive().getAsLong());
|
||||
return ZonedDateTime.ofInstant(instant, ZoneId.of(TIMEZONE));
|
||||
return ZonedDateTime.ofInstant(instant, UTC);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user