Valhalla Legends Forums Archive | Java Programming | SQL/Java Interaction

AuthorMessageTime
iago
I'm having a problem with timestamps. Calling an INSERT with a java.sql.Timestamp.toString() works fine, but when I pull it back out I end up with a string that looks like this:
20040213132931
And java.sql.Timestamp.valueOf(20040213132931) gives me this error:
[code]Exception in thread "main" java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss.fffffffff
at java.sql.Timestamp.valueOf(Timestamp.java:128)
at db.Assignment.set(Assignment.java:43)
at db.DB.get(DB.java:130)
at db.DB.main(DB.java:187)[/code]
Is there some way to convert it to a format like that, or am I stuck using a pile of yucky substrs?

Thanks!
February 13, 2004, 7:57 PM
iago
Solved: I was using ResultSet.getString(), which was converting it to a sttring. Now I'm using ResultSet.getObject() and taking care of it that way. Note that it is also possible to do ResultSet.getTimestamp(), but objects work better for me since i'm putting them in a Vector anyway.
February 13, 2004, 8:57 PM

Search