http-api: encode json Instants as millis since epoch
This commit is contained in:
@@ -43,12 +43,7 @@ public class InstantTypeAdapter extends TypeAdapter<Instant>
|
||||
return;
|
||||
}
|
||||
|
||||
out.beginObject()
|
||||
.name("seconds")
|
||||
.value(value.getEpochSecond())
|
||||
.name("nanos")
|
||||
.value(value.getNano())
|
||||
.endObject();
|
||||
out.value(value.toEpochMilli());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -60,6 +55,12 @@ public class InstantTypeAdapter extends TypeAdapter<Instant>
|
||||
return null;
|
||||
}
|
||||
|
||||
if (in.peek() == JsonToken.NUMBER)
|
||||
{
|
||||
long jsTime = in.nextLong();
|
||||
return Instant.ofEpochMilli(jsTime);
|
||||
}
|
||||
|
||||
long seconds = 0;
|
||||
int nanos = 0;
|
||||
in.beginObject();
|
||||
|
||||
Reference in New Issue
Block a user