Skip to content

Commit

Permalink
fix serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
gmckerrell authored Jul 6, 2020
1 parent 305b693 commit 2abada9
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,18 @@
*/
@ElideTypeConverter(type = Instant.class, name = "Instant")
public class InstantSerde implements Serde<String, Instant> {
// NB. ideally we would use ISO_INSTANT here but there is a bug in JDK-8 that
// means that parsing an ISO offset time doesn't work :-(
// https://bugs.openjdk.java.net/browse/JDK-8166138
private final static DateTimeFormatter FORMATTER = DateTimeFormatter.ISO_OFFSET_DATE_TIME;

@Override
public Instant deserialize(final String value) {
return Instant.from(
FORMATTER.parse(value)
// NB. ideally we would use ISO_INSTANT here but there is a bug in JDK-8 that
// means that parsing an ISO offset time doesn't work :-(
// https://bugs.openjdk.java.net/browse/JDK-8166138
DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(value)
);
}

@Override
public String serialize(final Instant value) {
return FORMATTER.format(value);
return DateTimeFormatter.ISO_INSTANT.format(value);
}
}

0 comments on commit 2abada9

Please sign in to comment.