Skip to content

Commit

Permalink
Convert SQL Timestamp to Instant to allow custom formatters
Browse files Browse the repository at this point in the history
  • Loading branch information
greek1979 committed Sep 6, 2022
1 parent 9d6aad9 commit fc0a724
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.sql.Timestamp;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAccessor;
import java.util.Locale;

/**
Expand All @@ -31,6 +32,12 @@ class SqlTimestampSerializer extends AbstractDateSerializer<Timestamp> {
super(serializerBuilder);
}

@Override
protected TemporalAccessor toTemporalAccessor(Timestamp value) {
// convert SQL Timestamp into an Instant so it can be cast to TemporalAccessor
return value.toInstant();
}

@Override
protected Instant toInstant(Timestamp value) {
return value.toInstant();
Expand Down

0 comments on commit fc0a724

Please sign in to comment.