Skip to content

Instantly share code, notes, and snippets.

@tuhin47
Created April 29, 2021 03:32
Show Gist options
  • Save tuhin47/9fc2da8d74ae9554a0416e678f75ee8b to your computer and use it in GitHub Desktop.
Save tuhin47/9fc2da8d74ae9554a0416e678f75ee8b to your computer and use it in GitHub Desktop.
Java Json Deserializer

Java Code

public class InstantTimeDeserializer extends JsonDeserializer<Instant> {
    @Override
    public Instant deserialize(JsonParser arg0, DeserializationContext arg1) throws IOException {
        return Instant.parse(arg0.getText());
    }
}

Usage

@JsonDeserialize(using = InstantTimeDeserializer.class)
private Instant createdAt;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment