class Audit {

    @PreUpdate
    @PrePersist
    public void setAuditFields(Object entity) {
        final LocalDateTime NOW = now();

        for (Field field : entity.getClass().getDeclaredFields()) {
            if (field.getAnnotation(Auditable.class) != null && field.getType().equals(Date.class)) {
                try {
                    LOGGER.finest(() -> format("Setting %s field %s to %s", entity.getClass(), field.getName(), NOW));
                    field.setAccessible(true);
                    field.set(entity, java.sql.Timestamp.valueOf(NOW));
                } catch (IllegalAccessException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }

}