PostgreSQL tips and tricks: Java 8
If you have not yet upgraded to Java 8, you are missing out nice features such as streams and enhanced date and time support.
java.time package (JSR-310) is a great improvement to the previous date and time API. For example,
java.time.LocalDate is a sane replacement of
java.sql.Date when all you want is actually a date, not a timestamp subject to timezone conversion issues.
Unfortunately, the JDBC’s public API did not change to accommodate these new types. You have to go through the
getObject methods, provided the underlying JDBC driver supports the new types.
So make sure your PostgreSQL driver version is greater than or equal to 9.4.1208 in order to take advantage of a date and time API that will not drive you crazy!