There\'s syntax that allows transforming a Timestamp into various date parts, including the unix epoch. This works as follows (in lastest PostgreSQL at least):
You can always resort to plain SQL with jOOQ:
public static Field extractEpochFrom(Field field) {
return DSL.field("extract(epoch from {0})", Integer.class, field);
}
There is currently (jOOQ 3.11) experimental support for additional, non standard DatePart
types, such as DatePart.EPOCH. It might work already with PostgreSQL, but not with other databases.
This support will be improved in future versions, including jOOQ 3.12, see: https://github.com/jOOQ/jOOQ/issues/7794