Skip to content
This repository was archived by the owner on Nov 12, 2025. It is now read-only.

Commit 5fb4e8b

Browse files
committed
Refactory code
1 parent cc18569 commit 5fb4e8b

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.searchcode.app.model;
2+
3+
import com.google.gson.*;
4+
5+
import java.lang.reflect.Type;
6+
import java.time.Instant;
7+
8+
public class InstantTypeAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
9+
10+
@Override
11+
public Instant deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
12+
return Instant.parse(jsonElement.getAsString());
13+
}
14+
15+
@Override
16+
public JsonElement serialize(Instant instant, Type type, JsonSerializationContext jsonSerializationContext) {
17+
return new JsonPrimitive(instant.toString());
18+
}
19+
}

0 commit comments

Comments
 (0)