22
22
import java .io .IOException ;
23
23
import java .io .Serializable ;
24
24
import java .math .BigDecimal ;
25
+ import java .sql .Time ;
25
26
import java .util .BitSet ;
26
27
import java .util .Calendar ;
27
- import java .util .Date ;
28
28
import java .util .Map ;
29
29
import java .util .TimeZone ;
30
30
@@ -266,7 +266,7 @@ protected Serializable deserializeTime(ByteArrayInputStream inputStream) throws
266
266
if (deserializeDateAndTimeAsLong ) {
267
267
return castTimestamp (timestamp , 0 );
268
268
}
269
- return timestamp != null ? new java .sql .Time (timestamp ) : null ;
269
+ return timestamp != null ? new java .sql .Timestamp (timestamp ) : null ;
270
270
}
271
271
272
272
protected Serializable deserializeTimeV2 (int meta , ByteArrayInputStream inputStream ) throws IOException {
@@ -294,7 +294,7 @@ protected Serializable deserializeTimeV2(int meta, ByteArrayInputStream inputStr
294
294
if (deserializeDateAndTimeAsLong ) {
295
295
return castTimestamp (timestamp , fsp );
296
296
}
297
- return timestamp != null ? new java . sql . Time (timestamp ) : null ;
297
+ return timestamp != null ? convertLongTimestamptWithFSP (timestamp , fsp ) : null ;
298
298
}
299
299
300
300
protected Serializable deserializeTimestamp (ByteArrayInputStream inputStream ) throws IOException {
@@ -312,7 +312,7 @@ protected Serializable deserializeTimestampV2(int meta, ByteArrayInputStream inp
312
312
if (deserializeDateAndTimeAsLong ) {
313
313
return castTimestamp (timestamp , fsp );
314
314
}
315
- return new java . sql . Timestamp (timestamp );
315
+ return convertLongTimestamptWithFSP (timestamp , fsp );
316
316
}
317
317
318
318
protected Serializable deserializeDatetime (ByteArrayInputStream inputStream ) throws IOException {
@@ -321,7 +321,7 @@ protected Serializable deserializeDatetime(ByteArrayInputStream inputStream) thr
321
321
if (deserializeDateAndTimeAsLong ) {
322
322
return castTimestamp (timestamp , 0 );
323
323
}
324
- return timestamp != null ? new java .util . Date (timestamp ) : null ;
324
+ return timestamp != null ? new java .sql . Timestamp (timestamp ) : null ;
325
325
}
326
326
327
327
protected Serializable deserializeDatetimeV2 (int meta , ByteArrayInputStream inputStream ) throws IOException {
@@ -354,7 +354,14 @@ protected Serializable deserializeDatetimeV2(int meta, ByteArrayInputStream inpu
354
354
if (deserializeDateAndTimeAsLong ) {
355
355
return castTimestamp (timestamp , fsp );
356
356
}
357
- return timestamp != null ? new java .util .Date (timestamp ) : null ;
357
+
358
+ return timestamp != null ? convertLongTimestamptWithFSP (timestamp , fsp ) : null ;
359
+ }
360
+
361
+ private java .sql .Timestamp convertLongTimestamptWithFSP (Long timestamp , int fsp ) {
362
+ java .sql .Timestamp ts = new java .sql .Timestamp (timestamp );
363
+ ts .setNanos (fsp * 1000 );
364
+ return ts ;
358
365
}
359
366
360
367
protected Serializable deserializeYear (ByteArrayInputStream inputStream ) throws IOException {
0 commit comments