代码之家  ›  专栏  ›  技术社区  ›  orbfish

JDBC ResultSet getDate失去精度

  •  27
  • orbfish  · 技术社区  · 14 年前

    我的ResultSet.getDate(x)调用正在丢失精度。基本上:

    rs = ps.executeQuery();
    rs.getDate("MODIFIED");
    

    3 回复  |  直到 14 年前
        1
  •  63
  •   Ypsilon Affe    10 年前
        2
  •  4
  •   dpatchery    14 年前

    您应该使用java.sql.Timestamp而不是java.sql.Date。如果需要,可以将其用作java.util.Date对象。

    rs = ps.executeQuery();
    Timestamp timestamp = rs.getTimestamp("MODIFIED");
    

        3
  •  0
  •   Ali    12 年前

    使用Timestap是正确的方法。

    我也遇到了一个问题。