Thread: jdbc timestamp-parsing

jdbc timestamp-parsing

From
Thomas Rohwer
Date:
There is a little typo in the code for getTimestamp
in the file jdbc1/ResultSet.java and jdbc2/ResultSet.java

  public Timestamp getTimestamp(int columnIndex) throws SQLException
  {
    String s = getString(columnIndex);
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd
HH:mm:sszzz");

    if (s != null)
      {
    int TZ = new Float(s.substring(19)).intValue();
    TZ = TZ * 60 * 60 * 1000;
    TimeZone zone = TimeZone.getDefault();
    zone.setRawOffset(TZ);
    String nm = zone.getID();
-->    s = s.substring(0,18) + nm; // should probably be s.substring(0,19)+
nm

which leads to an incorrect interpretation of timestamps:

timestamp:1999-01-03 18:35:47+01
date:1999-01-03 18:35:04.0

.


Thomas Rohwer