Believe me or not, pgjdbc has already that feature implemented.
pgsql-jdbc by date:
Соглашаюсь с условиями обработки персональных данных