@Override
    public Instant deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException {
        if (!(json instanceof JsonPrimitive))
            throw new JsonParseException("The instant should be a string value");
        else {
            Instant time = deserializeToInstant(json.getAsString());
            if (type == Instant.class)
                return time;
            else
                throw new IllegalArgumentException(this.getClass() + " cannot be deserialized to " + type);
        }
    }
@Test
    public void testDeserialize() {
        assertEquals(
                LocalDateTime.of(2017, 6, 8, 4, 26, 33)
                        .atOffset(ZoneOffset.UTC).toInstant(),
                InstantTypeAdapter.deserializeToInstant("2017-06-08T04:26:33+0000"));

        assertEquals(
                LocalDateTime.of(2021, 1, 3, 0, 53, 34)
                        .atOffset(ZoneOffset.UTC).toInstant(),
                InstantTypeAdapter.deserializeToInstant("2021-01-03T00:53:34+00:00"));

        assertEquals(
                LocalDateTime.of(2021, 1, 3, 0, 53, 34)
                        .atZone(ZoneId.systemDefault()).toInstant(),
                InstantTypeAdapter.deserializeToInstant("2021-01-03T00:53:34"));
    }