Skip to content

Commit 5c90000

Browse files
committed
Convert SQL Timestamp to Instant to allow custom formatters
1 parent 9d6aad9 commit 5c90000

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Diff for: src/main/java/org/eclipse/yasson/internal/serializer/types/SqlTimestampSerializer.java

+7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.sql.Timestamp;
1616
import java.time.Instant;
1717
import java.time.format.DateTimeFormatter;
18+
import java.time.temporal.TemporalAccessor;
1819
import java.util.Locale;
1920

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

35+
@Override
36+
protected TemporalAccessor toTemporalAccessor(Timestamp value) {
37+
// convert SQL Timestamp into an Instant so it can be cast to TemporalAccessor
38+
return value.toInstant();
39+
}
40+
3441
@Override
3542
protected Instant toInstant(Timestamp value) {
3643
return value.toInstant();

0 commit comments

Comments
 (0)