Skip to content

Commit

Permalink
fix(AbstractRowsEventDataDeserializer): add microsecond precision for…
Browse files Browse the repository at this point in the history
… datetime/timestamp
  • Loading branch information
glarwood committed Mar 31, 2020
1 parent 3f1bc55 commit a0090e5
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.math.BigDecimal;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;
import java.util.TimeZone;

Expand Down Expand Up @@ -312,7 +311,7 @@ protected Serializable deserializeTimestampV2(int meta, ByteArrayInputStream inp
if (deserializeDateAndTimeAsLong) {
return castTimestamp(timestamp, fsp);
}
return new java.sql.Timestamp(timestamp);
return convertLongTimestamptWithFSP(timestamp, fsp);
}

protected Serializable deserializeDatetime(ByteArrayInputStream inputStream) throws IOException {
Expand All @@ -321,7 +320,7 @@ protected Serializable deserializeDatetime(ByteArrayInputStream inputStream) thr
if (deserializeDateAndTimeAsLong) {
return castTimestamp(timestamp, 0);
}
return timestamp != null ? new java.util.Date(timestamp) : null;
return timestamp != null ? new java.sql.Timestamp(timestamp) : null;
}

protected Serializable deserializeDatetimeV2(int meta, ByteArrayInputStream inputStream) throws IOException {
Expand Down Expand Up @@ -354,7 +353,14 @@ protected Serializable deserializeDatetimeV2(int meta, ByteArrayInputStream inpu
if (deserializeDateAndTimeAsLong) {
return castTimestamp(timestamp, fsp);
}
return timestamp != null ? new java.util.Date(timestamp) : null;

return timestamp != null ? convertLongTimestamptWithFSP(timestamp, fsp) : null;
}

private java.sql.Timestamp convertLongTimestamptWithFSP(Long timestamp, int fsp) {
java.sql.Timestamp ts = new java.sql.Timestamp(timestamp);
ts.setNanos(fsp * 1000);
return ts;
}

protected Serializable deserializeYear(ByteArrayInputStream inputStream) throws IOException {
Expand Down

0 comments on commit a0090e5

Please sign in to comment.