For simplicity, this implementation makes the duration positive before proceeding. However, this can cause an
ArithmeticException to be thrown. E.g., this can occur if your duration is -2^63 seconds.
Durations can be represented as intervals in Postgres.
One incompatibility results from
Durations that are too large. This is due to (1)
long internally, and
ints; and (2) the conversion of days to months or
years being ambiguous.
Another results from
Durations being too precise; they have nanosecond precision, whereas Postgres has only
IllegalArgumentException will be thrown in these cases.
The handling of the second is subject to revision in the future; for example, it would be reasonable to have a
configurable truncation option.