[ 1715596 ] SQLJ Date problem in PostgreSQL

This commit is contained in:
Heng Sin Low 2007-05-09 23:37:57 +00:00
parent 39c44b6373
commit 23117ca11f
1 changed files with 16 additions and 2 deletions

View File

@ -65,9 +65,23 @@ public class Product
String serNo = rs.getString(2); String serNo = rs.getString(2);
if (serNo != null && serNo.length() > 0) if (serNo != null && serNo.length() > 0)
sb.append("#").append(serNo).append(" "); sb.append("#").append(serNo).append(" ");
Date guarantee = rs.getDate(3); Date guaranteeDate = null;
//either date or timestamp
Object guarantee = rs.getObject(3);
if (guarantee != null) if (guarantee != null)
sb.append(guarantee).append(" "); {
if (guarantee instanceof Timestamp)
{
Timestamp ts = (Timestamp)guarantee;
guaranteeDate = new Date(ts.getTime());
}
else
{
guaranteeDate = (Date)guaranteeDate;
}
}
if (guaranteeDate != null)
sb.append(guaranteeDate).append(" ");
} }
rs.close(); rs.close();
pstmt.close(); pstmt.close();