The methods in org.hsqldb.types.HsqlDateTime all fail to account for the ERA when operating on calendars, which prevents reading correct data. If the database has a temporal in the BC era, it always comes out in CE era instead.
In convertMillisFromCalendar and convertSecondsFromCalendar the target calendar also needs to copy over the era like so: targetCalendar.set(Calendar.ERA, sourceCalendar.get(Calendar.ERA));
Similarly in convertMillisToCalendar the like so: calendar.set(Calendar.ERA, tempCalGMT.get(Calendar.ERA));
resetToDate and resetToTime should probably also do cal.set(Calendar.ERA, GregorianCalendar.CE);
Hi Christian,
For dates (and timestamps) I followed the SQL Standard which allows 0001 to 9999 for the year and does not allow BCE values. This is enforced in date-time literals which do not allow BCE values. When using assignments via Java PreparedStatement etc. and arithmetics involving INTERVAL there is no range checking.
One can produce BC timestamps with
to_timestamp('BC 0001-01-01 00:00:00', 'BC YYYY-MM-DD HH:MI:SS').For future reference, it's good to know where there are no checks. Still, literals such as DATE 'BC 0001-01-01 00:00:00' are not allowed