@@ -72,7 +72,7 @@ public abstract class AbstractRowsEventDataDeserializer<T extends EventData> imp
7272 private final Map <Long , TableMapEventData > tableMapEventByTableId ;
7373
7474 private boolean deserializeDateAndTimeAsLong ;
75- private boolean deserializeInvalidDateAndTimeAsZero ;
75+ private Long invalidDateAndTimeRepresentation ;
7676 private boolean microsecondsPrecision ;
7777 private boolean deserializeCharAndBinaryAsByteArray ;
7878
@@ -84,8 +84,9 @@ void setDeserializeDateAndTimeAsLong(boolean value) {
8484 this .deserializeDateAndTimeAsLong = value ;
8585 }
8686
87- void setDeserializeInvalidDateAndTimeAsZero (boolean value ) {
88- this .deserializeInvalidDateAndTimeAsZero = value ;
87+ // value to return in case of 0000-00-00 00:00:00, 0000-00-00, etc.
88+ void setInvalidDateAndTimeRepresentation (Long value ) {
89+ this .invalidDateAndTimeRepresentation = value ;
8990 }
9091
9192 void setMicrosecondsPrecision (boolean value ) {
@@ -238,7 +239,7 @@ protected Serializable deserializeNewDecimal(int meta, ByteArrayInputStream inpu
238239 }
239240
240241 private Long castTimestamp (Long timestamp , int fsp ) {
241- if (timestamp != null && microsecondsPrecision ) {
242+ if (microsecondsPrecision && timestamp != null && timestamp > - 1 ) {
242243 return timestamp * 1000 + fsp % 1000 ;
243244 }
244245 return timestamp ;
@@ -414,7 +415,7 @@ protected byte[] deserializeJson(int meta, ByteArrayInputStream inputStream) thr
414415 protected Long asUnixTime (int year , int month , int day , int hour , int minute , int second , int millis ) {
415416 // https://dev.mysql.com/doc/refman/5.0/en/datetime.html
416417 if (year == 0 || month == 0 || day == 0 ) {
417- return deserializeInvalidDateAndTimeAsZero ? 0L : null ;
418+ return invalidDateAndTimeRepresentation ;
418419 }
419420 return UnixTime .from (year , month , day , hour , minute , second , millis );
420421 }
0 commit comments