import java.sql.*; import java.util.*; public class DateTest { public static void main(String args[]) throws Exception { Class.forName("org.postgresql.Driver"); Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/jurka","jurka",""); Statement stmt = conn.createStatement(); stmt.executeUpdate("CREATE TEMP TABLE tt (a date)"); stmt.close(); Calendar cal = Calendar.getInstance(); cal.set(2, 10, 30); java.sql.Date d = new java.sql.Date(cal.getTimeInMillis()); System.out.println("Inserting: " + d); PreparedStatement pstmt = conn.prepareStatement("INSERT INTO tt VALUES (?)"); pstmt.setDate(1,d); pstmt.executeUpdate(); pstmt.close(); stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM tt"); while (rs.next()) { System.out.println(rs.getDate(1)); } } }