import java.sql.*; import org.postgresql.PGStatement; public class InfTS { 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.execute("CREATE TEMP TABLE infts (a timestamptz)"); PreparedStatement pstmt = conn.prepareStatement("INSERT INTO infts VALUES (?)"); pstmt.setTimestamp(1, new Timestamp(PGStatement.DATE_POSITIVE_INFINITY)); pstmt.executeUpdate(); pstmt.setTimestamp(1, new Timestamp(PGStatement.DATE_NEGATIVE_INFINITY)); pstmt.executeUpdate(); ResultSet rs = stmt.executeQuery("SELECT * FROM infts"); while (rs.next()) { System.out.println(rs.getString(1)); System.out.println("Is +inf: " + (rs.getTimestamp(1).getTime() == PGStatement.DATE_POSITIVE_INFINITY)); System.out.println("Is -inf: " + (rs.getTimestamp(1).getTime() == PGStatement.DATE_NEGATIVE_INFINITY)); System.out.println(rs.getTimestamp(1)); } } }