24
24
import java .math .BigDecimal ;
25
25
import java .util .BitSet ;
26
26
import java .util .Calendar ;
27
- import java .util .Date ;
28
27
import java .util .Map ;
29
28
import java .util .TimeZone ;
30
29
@@ -312,7 +311,7 @@ protected Serializable deserializeTimestampV2(int meta, ByteArrayInputStream inp
312
311
if (deserializeDateAndTimeAsLong ) {
313
312
return castTimestamp (timestamp , fsp );
314
313
}
315
- return new java . sql . Timestamp (timestamp );
314
+ return convertLongTimestamptWithFSP (timestamp , fsp );
316
315
}
317
316
318
317
protected Serializable deserializeDatetime (ByteArrayInputStream inputStream ) throws IOException {
@@ -321,7 +320,7 @@ protected Serializable deserializeDatetime(ByteArrayInputStream inputStream) thr
321
320
if (deserializeDateAndTimeAsLong ) {
322
321
return castTimestamp (timestamp , 0 );
323
322
}
324
- return timestamp != null ? new java .util . Date (timestamp ) : null ;
323
+ return timestamp != null ? new java .sql . Timestamp (timestamp ) : null ;
325
324
}
326
325
327
326
protected Serializable deserializeDatetimeV2 (int meta , ByteArrayInputStream inputStream ) throws IOException {
@@ -354,7 +353,14 @@ protected Serializable deserializeDatetimeV2(int meta, ByteArrayInputStream inpu
354
353
if (deserializeDateAndTimeAsLong ) {
355
354
return castTimestamp (timestamp , fsp );
356
355
}
357
- return timestamp != null ? new java .util .Date (timestamp ) : null ;
356
+
357
+ return timestamp != null ? convertLongTimestamptWithFSP (timestamp , fsp ) : null ;
358
+ }
359
+
360
+ private java .sql .Timestamp convertLongTimestamptWithFSP (Long timestamp , int fsp ) {
361
+ java .sql .Timestamp ts = new java .sql .Timestamp (timestamp );
362
+ ts .setNanos (fsp * 1000 );
363
+ return ts ;
358
364
}
359
365
360
366
protected Serializable deserializeYear (ByteArrayInputStream inputStream ) throws IOException {
0 commit comments