import java.sql.*; import java.util.Calendar; public class TestDate2 { public static void main(String[] args) throws Exception { Class.forName("org.postgresql.Driver"); Connection conn = DriverManager.getConnection(args[0]); Statement stmt = conn.createStatement(); try { stmt.executeUpdate("DROP TABLE testdate2"); } catch (SQLException e) {} stmt.executeUpdate("CREATE TABLE testdate2(d date)"); stmt.executeUpdate("INSERT INTO testdate2(d) VALUES ('10000/02/01')"); PreparedStatement ps = conn.prepareStatement("INSERT INTO testdate2(d) VALUES (?)"); Calendar c = Calendar.getInstance(); c.set(Calendar.MONTH, 1); c.set(Calendar.DATE, 1); c.set(Calendar.YEAR, 10000); Date d = new Date(c.getTimeInMillis()); java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd G Z"); System.out.println("Inserting date: " + sdf.format(d)); ps.setDate(1, d); ps.executeUpdate(); ResultSet rs = stmt.executeQuery("SELECT d FROM testdate2"); while (rs.next()) { d = rs.getDate(1); System.out.println("Got date: " + sdf.format(d)); } rs.close(); stmt.close(); conn.close(); } }