I do understand that the reason behind problem I'm describing is an edge case and actually not even officially supported according to https://mariadb.com/kb/en/mariadb/date/ and https://mariadb.com/kb/en/mariadb/datetime/. However, I think it's possible that it could cause issues in other cases as well.
The Calendar instance used in MariaSelectResultSet.getTimestamp(byte, ColumnInformation, Calendar) is not cleared before values are set in the synchronized block on lines 1656 to 1665.
This doesn't normally cause any problems, but if the year part of the datetime value is 0000 and useLegacyDatetimeCode=false is used the Calendar instance is corrupted and won't produce correct timestamps afterwards.
As can be seen below, the first number 3 in the CalendarNotWorking output is clearly incorrect.
Output from the two attached samples: