1. Home
  2. Home
  3. Documentation
  4. Data types
  5. Date and time
Last reviewed Edit this page on GitHub

Date and time

The PostgreSQL® JDBC driver implements native support for the Java 8 Date and Time API (JSR-310) using JDBC 4.2.

Reviewed 2026-05-22 against source:ResultSet Java time mappings:704-745, PreparedStatement Java time mappings:1065-1074, PreparedStatement Java time OIDs:1545-1564

PostgreSQL®Java SE 8
DATELocalDate
TIME [ WITHOUT TIME ZONE ]LocalTime
TIME WITH TIME ZONEOffsetTime
TIMESTAMP [ WITHOUT TIME ZONE ]LocalDateTime
TIMESTAMP WITH TIME ZONEOffsetDateTime

This is closely aligned with tables B-4 and B-5 of the JDBC 4.2 specification.

Note

ZonedDateTime and Instant are not supported. Also note that OffsetDateTime instances for TIMESTAMP WITH TIME ZONE are returned in UTC (offset 0). This is because the backend stores them as UTC.

Example 5.2. Reading Java 8 Date and Time values using JDBC

Reviewed 2026-05-22 against source:ResultSet#getObject Java time dispatch:4048-4056, ResultSet Java time tests:168-202, ResultSet timestamp tests:338-370

Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("SELECT * FROM mytable WHERE columnfoo = 500");
while (rs.next()) {
    System.out.print("Column 1 returned ");
    LocalDate localDate = rs.getObject(1, LocalDate.class);
    System.out.println(localDate);
}
rs.close();
st.close();

For other data types simply pass other classes to #getObject.

Note

The Java data types need to match the SQL data types in Table 5.1.

Reviewed 2026-05-22 against source:PreparedStatement#setObject Java time dispatch:1065-1074, PreparedStatement Java time OIDs:1545-1564, PreparedStatement Java time tests:226-355, PreparedStatement time tests:458-496

LocalDate localDate = LocalDate.now();
PreparedStatement st = conn.prepareStatement("INSERT INTO mytable (columnfoo) VALUES (?)");
st.setObject(1, localDate);
st.executeUpdate();
st.close();