Hi all,
Here's my setup:
MS SQL 2000 server
2 DateTime fields in table SystemInfo (you can only have 1 Timestamp, so I need to use DateTime)
My problem is that I need to recored both the date and time in the DateTime field, but java.sql.date ignores the hours/minutes/seconds part. I've done some debugging, and the trim occurs
before the execute call. Is there a good way to preserve the whole Date value when going to java.sql.date? Here's my code:
System.out.println("Update System Info");
sql.clearBatch();
sql = conn.prepareStatement("update SystemInfo set Created=?, Modified=? where Parent = ?");
sql.setDate(1, new java.sql.Date(sys.getCreated().getTime()));
System.out.println(new java.sql.Date(sys.getCreated().getTime()));
sql.setDate(2, new java.sql.Date(sys.getLastModified().getTime()));
sql.setString(3, parent.toString());
//sql.executeUpdate();
So after I create a new java.util.Date, print it, package it into my sys object (sys.getCreated() returns a java.util.Date),
send it to the block above, here's the output:
Wed Jun 11 16:55:25 EDT 2003
Update System Info
2003-06-11
What's the right way to do this? Thanks !
Jim