为什么从结果集JDBC中提取的值与我在psql
中得到的值不同?
我已经尝试过将类型强制转换为::int
PreparedStatement test_ps = this.prepareStatement("select EXTRACT(EPOCH FROM NOW() - '2019-01-12 09:29:12.086416'::timestamp)::int AS timediff");
ResultSet test_rs = test_ps.executeQuery();
while (test_rs.next()) {
System.out.println("TIMEDIFF:");
System.out.println(test_rs.getInt("timediff"));
}
我从psql
获得的输出是:
mything=# select EXTRACT(EPOCH FROM NOW() - '2019-01-12
09:29:12.086416'::timestamp)::int AS timedif;
timedif
---------
1149
(1 row)
我从JDBC获得的输出是:
TIMEDIFF:
-24011
现在,时间大约是:
mything=# select now();
now
-------------------------------
2019-01-12 09:54:17.795061+00
(1 row)