mirror of
https://github.com/plexusorg/Plex.git
synced 2026-06-04 05:26:55 +00:00
Expose ZDT to the API
This commit is contained in:
@@ -6,6 +6,7 @@ plugins {
|
|||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("io.papermc.paper:paper-api:26.1.2.build.+")
|
compileOnly("io.papermc.paper:paper-api:26.1.2.build.+")
|
||||||
compileOnly("org.apache.logging.log4j:log4j-api:2.26.0")
|
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")
|
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.JsonPrimitive;
|
||||||
import com.google.gson.JsonSerializationContext;
|
import com.google.gson.JsonSerializationContext;
|
||||||
import com.google.gson.JsonSerializer;
|
import com.google.gson.JsonSerializer;
|
||||||
import dev.plex.util.TimeUtils;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
@@ -16,7 +14,7 @@ import java.time.ZonedDateTime;
|
|||||||
|
|
||||||
public class ZonedDateTimeAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<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
|
@Override
|
||||||
public JsonElement serialize(ZonedDateTime src, Type typeOfSrc, JsonSerializationContext context)
|
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
|
public ZonedDateTime deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
||||||
{
|
{
|
||||||
Instant instant = Instant.ofEpochMilli(json.getAsJsonPrimitive().getAsLong());
|
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