package co.phoenixlab.discord.util.adapters;

import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;

import java.io.IOException;
import java.time.Instant;

public class InstantGsonTypeAdapter extends TypeAdapter<Instant> {

    @Override
    public void write(JsonWriter out, Instant value) throws IOException {
        if (value == null) {
            out.nullValue();
        } else {
            out.value(value.toEpochMilli());
        }
    }

    @Override
    public Instant read(JsonReader in) throws IOException {
        if (in.peek() == JsonToken.NULL) {
            return null;
        }
        long epoch = in.nextLong();
        return Instant.ofEpochMilli(epoch);
    }
}

@@ -503,16 +503,59 @@
     out.
+beginObject();%0A            out.name(%22sec%22).
 value(va
@@ -562,22 +562,107 @@
 lue.
+ge
 t
-o
 Epoch
-Milli()
+Second());%0A            out.name(%22nanos%22).value(value.getNano());%0A            out.endObject(
 );%0A 
@@ -846,27 +846,374 @@
 ong 
-epoch = in.nextLong
+sec = 0L;%0A        int nanos = 0;%0A        in.beginObject();%0A        while (in.hasNext()) %7B%0A            switch (in.nextName()) %7B%0A                case %22sec%22:%0A                    sec = in.nextLong();%0A                    break;%0A                case %22nanos%22:%0A                    nanos = in.nextInt();%0A                    break;%0A            %7D%0A        %7D%0A        in.endObject
 ();%0A
@@ -1246,19 +1246,25 @@
 poch
-Milli(epoch
+Second(sec, nanos
 );%0A 

Change format of Instant to allow full represent